/**
 * Created by xxx on 2017年12月4日.
 */
var currentpage = 1,totlepage = 1,i,BusUE,goodUE,amap,posiResult = {};//分页的当前页和总的页数
//当前第几页、总页数、总行数
var otherData = {pageLeft:0,pageRight:0};
//分页
var Page = React.createClass({
    setPage: function (e) {
        setPage($(e.target).html());
        this.props.onPageClick(1);
    },
    showPage: function () {
        showPage();
    },
    render: function () {
        {
            var items = [],
                svar = this;
            if(totlepage == 0 ){
                items.push({num:1,checked:true})
            }else if(totlepage < 6){
                for(i = 1;i <= totlepage ;i++) {
                    if (i == currentpage) {
                        items.push({num:i,checked:true})
                    } else {
                        items.push({num:i,checked:false})
                    }
                }
            }else if(currentpage >= (totlepage-2)) {//点在左边
                items.push({num:1,checked:false});
                items.push({num:'···',checked:false});
                for(i = totlepage-2;i <= totlepage ;i++){
                    if(i == currentpage){
                        items.push({num:i,checked:true})
                    }else{
                        items.push({num:i,checked:false})
                    }
                }
            }else if(currentpage <= 3){
                for(i = 1;i <= 3 ;i++) {
                    if (i == currentpage) {
                        items.push({num:i,checked:true})
                    } else {
                        items.push({num:i,checked:false})
                    }
                }
                items.push({num:'···',checked:false});
                items.push({num:totlepage,checked:false})
            }else {//点在两边
                items.push({num:1,checked:false});
                items.push({num:'···',checked:false});
                items.push({num:currentpage-1,checked:false});
                items.push({num:currentpage,checked:true});
                items.push({num:currentpage+1,checked:false});
                items.push({num:'···',checked:false});
                items.push({num:totlepage,checked:false})
            }
        }
        return (
            <div className="studentsInfo-page tableInfo-page">
                <div className="page-number">每页<span className="page-number-list" onClick={this.showPage}>{pagecount}</span>条</div>
                <div className="page-list" style={{top:pageListTop+"px"}}>
                    <ul>
                        {
                            pageList.map(function (item) {
                                return (<li onClick={svar.setPage}>{item}</li>)
                            })
                        }
                    </ul>
                </div>
                <div className="page-limit">
                    <ol className="page-limit-ol">
                        <li className="page-limit-img" name="-1" onClick={otherData.pageLeft == 0?'':svar.props.onPageClick.bind(svar,-1)} ><span className={otherData.pageLeft == 0?'page-limit-left-no':'page-limit-left-yes'}/></li>
                        {
                            items.map(function (item) {
                                return (<li onClick={isNaN(item.num)?'':svar.props.onPageClick.bind(svar,item.num)} className={item.checked == true?'page-limit-num page-limit-checked':'page-limit-num'} name={item.num}>{item.num}</li>)
                            })
                        }
                        <li className="page-limit-img" name="-2" onClick={otherData.pageRight == 0?'':svar.props.onPageClick.bind(svar,-2)}><span className={otherData.pageRight == 0?'page-limit-right-no':'page-limit-right-yes'}/></li>
                    </ol>
                </div>
            </div>
        );
    },
});

//父组件
var Main = React.createClass({
    //组件初始状态
    getInitialState: function () {
        return {
            otherData: this.props.otherData,//分页数据
            tableData: [],//显示商家管理表单的数据
            useDetailsData: [],//商家详情>商品详情>使用情况 数据
            busExaTableData: [],//显示商家审核表单的数据
            menuType: 1,//1:列表 2：审核
            operateType: '餐饮美食',//经营类别下拉框值
            navigation: '',//导航内容
            busManPageInfo: {
                currentpage:1,//当前页
                pageLeft: 0,//0是不可点击，1反之
                pageRight: 0,//0是不可点击，1反之
                totlepage: 1,//总页数
            },//商家列表查询的数据分页信息
            busExaPageInfo: {
                currentpage:1,//当前页
                pageLeft: 0,//0是不可点击，1反之
                pageRight: 0,//0是不可点击，1反之
                totlepage: 1,//总页数
            },//商家审核号查询的数据分页信息
            droupName:'商家名称',//下拉列表  商家名称 商家手机号 区域 经营类别
            busTrData: [],//商家列表 商家审核 选中行数据
            businessDataList:[],//商家列表数据
            businessDataAll:[],//商家列表数据
            imgData: [
                {updateImg: false,showImg: false,imgUrl:''},
                {updateImg: false,showImg: false,imgUrl:''},
                {updateImg: false,showImg: false,imgUrl:''},
                {updateImg: false,showImg: false,imgUrl:''},
                {updateImg: false,showImg: false,imgUrl:''},
                {updateImg: false,showImg: false,imgUrl:''},
            ],//imgData[0] _logo商家logo imgData[1] _busLi 营业执照 imgData[2]_header 图片头图 imgData[3]_goodsDetails 图片详情图 imgData[4]_coupon 优惠券图片 imgData[5] _busHeader 商家头图
            addressData: [],//新增商家-已选选择的地区数据
            /**
             * 商品
             */
            goodsTableData: [],//显示商品管理表单的数据
            goodsManPageInfo: {
                currentpage:1,//当前页
                pageLeft: 0,//0是不可点击，1反之
                pageRight: 0,//0是不可点击，1反之
                totlepage: 1,//总页数
            },//商品列表列表查询的数据分页信息
            goodsTrData: [],//商品列表——行数据
            addressOrType: {
                isShowAddress: true,//是否显示商家地址
                parent: false,//是否家长
                teacher: false,//是否老师
                china: false,//是否显示省市区
            },
            useDetailsInfo:{ //商品使用详情列表查询 查询状态
                orderProp: 1,
                type: 'ASC',
            },
            isOnLoad: false,//是否加载出数据
            isShowMap: false,//是否显示地图
            goodsPackageData: [],//套餐数据
        }
    },
    /**
     * 获取默认图片
     * @param e
     */
    defaultImg(e){
        e.target.src = '../img/image/splitImg.jpg';
    },
    componentDidMount: function () {
        suixun.hideLoding();//显示加载中
        this.getBusinessPassList();
        this.getBusinessTableDate(1,this.state.menuType,this.state.droupName);
        BusUE = suixun.editor('busiTintroduce');//初始化富文本
        $(document).keypress(function(e) {
            var eCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
            if (eCode == 13){
                if($("#businessQuery").is(":focus")){
                    this.getBusinessTableDate(1,this.state.menuType,this.state.droupName);
                    this.setNavigation('搜索结果');
                }
            }
        }.bind(this));
        //地图加载堵塞
        let intTime = setInterval(function () {
            if(this.state.isOnLoad){
                setTimeout(function () {
                    window.clearInterval(intTime);
                },1100);
                suixun.hideLoding();
            }
        }.bind(this),300);
    },
    /**
     * 获取所有商户
     */
    getBusinessList: function () {
        suixun.showLoding();//显示加载中
        suixun.ajax(serverUrl+'/credits/company/find_all_name.json','',"get",function(data){
            suixun.hideLoding();//隐藏加载中
            if(data.code == 200 ){
                for(var i=0;i<data.info.list.length;i++){
                    this.state.businessDataList[i] = {key:i,name:data.info.list[i]};
                }
                this.setState({businessDataList:this.state.businessDataList,businessDataAll:this.state.businessDataList});
            }else{
                this.setState({businessDataList:this.state.businessDataList,businessDataAll:this.state.businessDataList});
            }
        }.bind(this));
    },
    /**
     * 获取所有商户
     */
    getBusinessPassList: function () {
        suixun.showLoding();//显示加载中
        suixun.ajax(serverUrl+'/credits/company/find_all_pass_name.json','',"get",function(data){
            suixun.hideLoding();//隐藏加载中
            if(data.code == 200 ){
                if(data.info.list){
                    this.setState({businessDataList:data.info.list,businessDataAll:data.info.list});
                }else{
                    this.setState({businessDataList:[],businessDataAll:[]});
                }
            }else{
                this.setState({businessDataList:[],businessDataAll:[]});

            }
        }.bind(this));
    },
    /**
     * 获取商家列表 商家审核的数据
     * @param page 当前页数
     * @param menuType 商家列表 商家审核
     * @param droupName 商家列表 商家审核 搜索下拉框列表
     */
    getBusinessTableDate: function(page,menuType,droupName){
        var start = 0;//计算查询记录数据库开始位置
        if(page>1){
            start = (page-1)*pagecount;
        }
        var params = 'start='+start+'&length='+pagecount,
            value = $("#businessQuery").val(),
            url = '';
        var searchType = 1;
        switch (droupName){
            case '商家手机号':
                searchType = 2;
                break;
            case '区域':
                searchType = 3;
                break;
            case '经营类别':
                searchType = 4;
                break;
            default:
                searchType = 1;
                break;
        }
        params += '&searchType='+searchType+'&value='+value;
        if(menuType==1){//商家列表
            url = serverUrl+'/credits/company/find_page.json?'+params+'&auditState='+2;//+'&auditState[0]='+2
        }else if(menuType==2) {//商家审核
            url = serverUrl+'/credits/company/find_page.json?'+params+'&auditState='+[0,1];
        }
        suixun.showLoding();//显示加载中
        suixun.ajax(url,'',"get",function(data){
            suixun.hideLoding();
            this.setState({isOnLoad:true});
            if(data.code == 200){
                var pageInfo = {};
                if(data.info.total==0){
                    currentpage = 1;
                    otherData.pageLeft = 0;
                    otherData.pageRight = 0;
                    totlepage = 1;//初始化的时候赋值：分页的当前页和总的页数
                }else{
                    pageInfo = suixun.getPageInfo(start, pagecount, data.info.total);
                    currentpage = pageInfo.currentpage;
                    otherData.pageLeft = pageInfo.pageLeft;
                    otherData.pageRight = pageInfo.pageRight;
                    totlepage = pageInfo.totlepage;//初始化的时候赋值：分页的当前页和总的页数}
                }
                if(menuType==1){//商家列表
                    this.setState({tableData:data.info.list==null?[]:data.info.list,otherData:otherData,busManPageInfo:pageInfo});
                }else if(menuType==2) {//商家审核
                    this.setState({busExaTableData:data.info.list==null?[]:data.info.list,otherData:otherData,busExaPageInfo:pageInfo});
                }
            }else{
                suixun.alert(data.msg,function (data) {
                    if(data){
                        var pageInfo ={
                            currentpage:1,
                            pageLeft: 0,
                            pageRight: 0,
                            totlepage: 1,
                        };
                        currentpage = 1;
                        otherData.pageLeft = 0;
                        otherData.pageRight = 0;
                        totlepage = 1;//初始化的时候赋值：分页的当前页和总的页数
                        if(menuType==1){//商家列表
                            this.setState({tableData:[],otherData:otherData,busManPageInfo:pageInfo});
                        }else if(menuType==2) {//商家审核
                            this.setState({busExaTableData:[],otherData:otherData,busExaPageInfo:pageInfo});
                        }
                    }
                }.bind(this))
            }
        }.bind(this));
    },
    /**
     * 获取商品列表的数据
     * @param page 显示页
     */
    getGoodSTableDate: function(page){
        var start = 0;//计算查询记录数据库开始位置
        if(page>1){
            start = (page-1)*pagecount;
        }
        var params = 'start='+start+'&length='+pagecount+'&companyid='+this.state.busTrData.id;
        suixun.showLoding();//显示加载中
        suixun.ajax( serverUrl+'/credits/goods/archives/find_page_company.json?'+params,'',"get",function(data){
            suixun.hideLoding();
            if(data.code == 200){
                var pageInfo = {};
                if(data.info.total==0){
                    currentpage = 1;
                    otherData.pageLeft = 0;
                    otherData.pageRight = 0;
                    totlepage = 1;//初始化的时候赋值：分页的当前页和总的页数
                }else {
                    pageInfo = suixun.getPageInfo(start, pagecount, data.info.total);
                    currentpage = pageInfo.currentpage;
                    otherData.pageLeft = pageInfo.pageLeft;
                    otherData.pageRight = pageInfo.pageRight;
                    totlepage = pageInfo.totlepage;//初始化的时候赋值：分页的当前页和总的页数}
                }
                this.setState({goodsTableData:data.info.list==null?[]:data.info.list,otherData:otherData,goodsManPageInfo:pageInfo});
            }else{
                suixun.alert(data.msg,function (data) {
                    if(data){
                        var pageInfo ={
                            currentpage:1,
                            pageLeft: 0,
                            pageRight: 0,
                            totlepage: 1,
                        };
                        currentpage = 1;
                        otherData.pageLeft = 0;
                        otherData.pageRight = 0;
                        totlepage = 1;//初始化的时候赋值：分页的当前页和总的页数
                        this.setState({goodsTableData:[],otherData:otherData,goodsManPageInfo:pageInfo});

                    }
                }.bind(this))
            }
        }.bind(this));
    },
    /**
     * 获取商家详情-商品详情-使用情况的数据
     * @param page 显示页
     */
    getUseDetailsData: function(page,orderProp,type){
        var start = 0;//计算查询记录数据库开始位置
        if(page>1){
            start = (page-1)*pagecount;
        }
        var params = 'start='+start+'&length='+pagecount+'&archivesid='+this.state.goodsTrData.id+'&orderProp='+orderProp+'&type='+type;
        suixun.showLoding();//显示加载中
        suixun.ajax( serverUrl+'/credits/goods/archives/find_goods_page.json?'+params,'',"get",function(data){
            suixun.hideLoding();
            if(data.code == 200){
                var pageInfo = {};
                if(data.info.total==0){
                    currentpage = 1;
                    otherData.pageLeft = 0;
                    otherData.pageRight = 0;
                    totlepage = 1;//初始化的时候赋值：分页的当前页和总的页数
                }else {
                    pageInfo = suixun.getPageInfo(start, pagecount, data.info.total);
                    currentpage = pageInfo.currentpage;
                    otherData.pageLeft = pageInfo.pageLeft;
                    otherData.pageRight = pageInfo.pageRight;
                    totlepage = pageInfo.totlepage;//初始化的时候赋值：分页的当前页和总的页数}
                }
                this.setState({useDetailsData:data.info.list==null?[]:data.info.list,otherData:otherData});
            }else{
                suixun.alert(data.msg,function (data) {
                    if(data){
                        var pageInfo ={
                            currentpage:1,
                            pageLeft: 0,
                            pageRight: 0,
                            totlepage: 1,
                        };
                        currentpage = 1;
                        otherData.pageLeft = 0;
                        otherData.pageRight = 0;
                        totlepage = 1;//初始化的时候赋值：分页的当前页和总的页数
                        this.setState({useDetailsData:[],otherData:otherData});

                    }
                }.bind(this))
            }
        }.bind(this));
    },
    /**
     * 分页
     * @param num
     */
    onPageClick: function (num) {
        if(num > 0){
            currentpage = num;
        }else if(num == -1 && currentpage > 1){
            currentpage --;
        }else if(num == -2  && currentpage < totlepage){
            currentpage ++;
        }
        console.log(currentpage);
        if(this.state.navigation=='商家详情'&&this.state.menuType==1) {
            this.getGoodSTableDate(currentpage);
        }else if(this.state.navigation=='商家详情>商品详情>使用情况'&&this.state.menuType==1){
            this.getUseDetailsData(currentpage,this.state.useDetailsInfo.orderProp, this.state.useDetailsInfo.type);
        }else{
            this.getBusinessTableDate(currentpage,this.state.menuType,this.state.droupName);
        }
    },
    /**
     * 设置商品使用情况状态
     */
    setUseDetailsInfo: function (orderProp, type) {
        this.setState({useDetailsInfo:{
            orderProp: orderProp,
            type: type
        }});
        this.getUseDetailsData(1, orderProp, type);
    },
    /**
     * 设置导航名称
     * @return {XML}
     */
    setNavigation: function (name) {
        if(name==''){
            $('#businessQuery').val('');
            this.getBusinessTableDate(1,this.state.menuType,this.state.droupName);
            this.setBusinessInfo();
        }else if(name=='搜索结果'){
            this.getBusinessTableDate(1,this.state.menuType,this.state.droupName);
        }
        if(name=='商家详情'&&this.state.menuType==1) {
            this.getGoodSTableDate(1);
        }
        if(name == '商家详情>商品详情'){
            this.setState({useDetailsInfo:{
                orderProp: 2,
                type: 'DESC'
            }});
        }
        if(name == '商家详情>商品详情>使用情况'){
            this.getUseDetailsData(1, 2, 'DESC');
            this.setState({useDetailsInfo:{
                orderProp: 2,
                type: 'DESC'
            }});
        }
        if(name=='新建商家' || name=='商家详情' || name=='编辑商家'){
            if(name=='商家详情'){
                BusUE.setDisabled('fullscreen');
            }else{
                BusUE.setEnabled();
            }
        }
        this.setState({navigation:name,goodsPackageData: []})
    },
    /**
     * 制空-新建商家的表单
     */
    setBusinessInfo: function () {
        $('#busiName').val('');//商户名
        $('#operateType').val('餐饮美食');//经营类别
        $('#operateTypeOther').val('');//经营类别——其他
        $('#busiUserName').val('');//联系人
        $('#busiUserTitle').val('');//联系人职称
        $('#busiUserPhone').val('');//联系人电话
        $('#busiGoodsNumber').val('2');//商品限制个数
        $('#businessScore').val('0');//商家评分
        $('#busiLoginAccount').val('');//登录账号
        BusUE.ready(function() {//编辑器初始化完成再赋值
            BusUE.setContent('');  //赋值给UEditor
        });
        //商家地址、合作意向区域
        $('.span-provinceid1,.span-provinceid2').text('选择省份');//省
        $('.span-cityid1,.span-cityid2').text('选择地区');//市
        $('.span-countyid1,.span-countyid2').text('选择县或街道');//区
        $('#adressDetails').val('');//
        //已选地区
        this.setState({addressData: [],operateType:'餐饮美食'});
        this.setImgData();//制空图片
    },
    /**
     * 新增商户
     *
     */
    addBusiness: function () {
        var busiName = $('#busiName').val();//商户名
        var operateType = $('#operateType').val();//经营类别
        var operateTypeOther = $('#operateTypeOther').val();//经营类别——其他
        var busiUserName = $('#busiUserName').val();//联系人
        var busiUserTitle = $('#busiUserTitle').val();//联系人职称
        var busiUserPhone = $('#busiUserPhone').val();//联系人电话
        var busiLoginAccount = $('#busiLoginAccount').val();//登录账号
        var busiGoodsNumber = $('#busiGoodsNumber').val();//商品限制个数
        var businessScore = $('#businessScore').val();//商家评分
        var busiTintroduce = BusUE.getContent();//获取编辑的内容$('#busiTintroduce').val();//商家介绍
        //商家地址
        var provinceid1 = $('.span-provinceid1').text();//省
        var cityid1 = $('.span-cityid1').text();//市
        var countyid1 = $('.span-countyid1').text();//区
        var adressDetails = $('#adressDetails').val();//
        //合作意向区域---已选地区
        var addressData = this.state.addressData;

        /**
         * 验证
         */
        //商户名
        if(busiName == ''){
            suixun.alert('商户名不能为空！');
            return;
        }
        //经营类别
        if(operateType == '其他' && operateTypeOther==''){
            suixun.alert('经营类别不能为空！');
            return;
        }
        //联系人
        if(busiUserName == ''){
            suixun.alert('联系人不能为空！');
            return;
        }
        //联系人职称
        if(busiUserTitle == ''){
            suixun.alert('联系人职称不能为空！');
            return;
        }
        //联系人电话
        if(busiUserPhone == ''){
            suixun.alert('联系人电话不能为空！');
            return;
        }else if(!/^[0-9]*$/.test(busiUserPhone)){
            suixun.alert('联系人电话格式不对！');
            return;
        }
        // //商品限制个数
        // if(busiGoodsNumber == ''){
        //     busiGoodsNumber = 2;
        // }else if(!/^[0-9]*$/.test(busiGoodsNumber)){
        //     suixun.alert('商品限制个数格式不对！');
        //     return;
        // }else if(busiGoodsNumber>9 || busiGoodsNumber<0){
        //     suixun.alert('商品限制个数为0~9！');
        //     return;
        // }
        //商家地址
        if(provinceid1 =='选择省份' || cityid1=='选择地区' || countyid1=='选择县或街道' || adressDetails==''){
            if(adressDetails==''){
                suixun.alert('请填写商家详细地址！');
                return;
            }else{
                suixun.alert('请选择完整的省市区地址！');
                return;
            }
        }
        // else if(provinceid1+cityid1+countyid1==adressDetails || cityid1+countyid1==adressDetails){
        //     suixun.alert('请填写商家详细地址！');
        //     return;
        // }
        //已选择合作意向区域
        if(addressData.length==0){
            suixun.alert('已选择合作意向区域不能为空！');
            return;
        }
        //登录账号
        if(busiLoginAccount == ''){
            suixun.alert('登录账号不能为空！');
            return;
        }else if(busiLoginAccount.length != 11 || !/^[0-9]*$/.test(busiLoginAccount)){
            suixun.alert('登录账号格式不对！');
            return;
        }
        //商家logo
        if(this.state.imgData[0].imgUrl==''){
            suixun.alert('请上传商家logo图片！');
            return;
        }
        //商家头图
        if(this.state.imgData[5].imgUrl==''){
            suixun.alert('请上传商家头图！');
            return;
        }
        //营业执照
        if(this.state.imgData[1].imgUrl==''){
            suixun.alert('请上传营业执照logo图片！');
            return;
        }
        //商家介绍
        if(busiTintroduce == ''){
            suixun.alert('商家介绍不能为空！');
            return;
        }else{
            busiTintroduce = busiTintroduce.replace(/<table/g,'<div style="overflow: auto;  width: 100%;"><table');
            busiTintroduce = busiTintroduce.replace(/<\/table>/g,'<\/table><\/div>');
            busiTintroduce = encodeURIComponent(busiTintroduce);
        }
        var addressDataString = '';
        for(var i = 0;i < addressData.length;i++){
            addressDataString += addressData[i].province+' '+addressData[i].city+' '+addressData[i].town+',';
        }
        /**
         * 组装地址
         * @type {string}
         */
        let address = provinceid1+'-'+cityid1+'-'+countyid1+'-'+adressDetails.replace(provinceid1,'').replace(cityid1,'').replace(countyid1,'')+'-'+document.getElementById('adressDetailsInfo').innerHTML.replace(',','-');
        /**
         * 组装数据-JSON
         */
        var paramData = {
            name: busiName,
            businessType: operateType,
            linkPeople: busiUserName,
            linkPeopleJob: busiUserTitle,
            linkPhone: busiUserPhone,
            goodsShowNum: busiGoodsNumber,
            level: businessScore,
            address: address,
            intentArea: addressDataString.substring(0,addressDataString.length-1),//addressData.toString()
            account: busiLoginAccount,
            introduce: busiTintroduce,
        };
        if(operateType=='其他'){
            paramData.businessType = operateTypeOther;
        }
        suixun.showLoding();//显示加载中
        if(this.state.navigation=='新建商家'){
            suixun.uploadImg('#file_logo','',function (img_logo) {//_logo
                suixun.uploadImg('#file_busHeader','',function (img_busHeader) {//_busHeader
                    suixun.uploadImg('#file_busLi','',function (img_busLi) {//_busLi
                        paramData['companyImgs'] = suixun.imagesUrl+img_busHeader;
                        paramData['logo'] = suixun.imagesUrl+img_logo;
                        paramData['businessLicence'] = suixun.imagesUrl+img_busLi;
                        this.changeBusiness(serverUrl+'/credits/company/insert.json',paramData);
                    }.bind(this));
                }.bind(this));
            }.bind(this));
        }else if(this.state.navigation=='编辑商家'){//编辑商家
            paramData['id'] = this.state.busTrData.id;//商家ID
            let img_logo_b = false,
                img_busHeader_b = false,
                img_busLi_b = false,
                logo = this.state.busTrData.logo,
                busHeader = this.state.busTrData.companyImgs,
                busLi = this.state.busTrData.businessLicence,
                interval = '';
            if(this.state.imgData[0].updateImg){
                suixun.uploadImg('#file_logo','',function (img_logo) {//_logo
                    logo = suixun.imagesUrl+img_logo;
                    img_logo_b = true;
                }.bind(this));
            }else{
                img_logo_b = true;
            }
            if(this.state.imgData[5].updateImg){
                suixun.uploadImg('#file_busHeader','',function (img_busHeader) {//_busHeader
                    busHeader = suixun.imagesUrl+img_busHeader;
                    img_busHeader_b = true
                }.bind(this));
            }else{
                img_busHeader_b = true
            }
            if(this.state.imgData[1].updateImg){
                suixun.uploadImg('#file_busLi','',function (img_busLi) {//_busLi
                    busLi = suixun.imagesUrl+img_busLi;
                    img_busLi_b = true
                }.bind(this));
            }else{
                img_busLi_b = true
            }
            interval = setInterval(function () {
                if(img_logo_b && img_busHeader_b && img_busLi_b){
                    paramData['companyImgs'] = busHeader;
                    paramData['logo'] = logo;
                    paramData['businessLicence'] = busLi;
                    this.changeBusiness(serverUrl+'/credits/company/update.json',paramData);
                    window.clearInterval(interval);
                }
            }.bind(this),500);

        }
    },
    /**
     *
     * 新增、编辑商家
     * @param url
     * @param paramData
     */
    changeBusiness: function (url,paramData) {
        suixun.showLoding();//显示加载中
        suixun.ajax(url,JSON.stringify(paramData),"post",function(data){
            suixun.hideLoding();//隐藏加载中
            if(data.code == 200){
                suixun.alert('操作成功!',function (data) {
                    if(data){
                        this.setNavigation('');
                        this.getBusinessPassList();
                        this.onPageClick(currentpage);
                    }
                }.bind(this));
            }else{
                suixun.alert(data.msg);
            }
        }.bind(this),"application/json; charset=utf-8");
    },

    /**
     * 切换菜单点击按钮
     * @return {XML}
     */
    changeMenu: function (type) {
        if(type==this.state.menuType){
            return;
        }
        if(type==1){
            this.getBusinessPassList();
        }else{
            this.getBusinessList();
        }
        $("#businessQuery").val('');//搜索框制空
        this.getBusinessTableDate(1,type,'商家名称');
        this.setState({menuType:type,droupName:'商家名称'});
    },
    /**
     * 设置下拉选择框内容
     * @return {XML}
     */
    setDroup: function (name) {
        if(name != this.state.droupName){
            $("#businessQuery").val('');
        }
        this.setState({droupName:name});
    },
    /**
     * 点击搜索输入框
     * @return {XML}
     */
    onClickQueryInput: function (e) {
        if(this.state.droupName == "商家名称"){
            this.schoolArray($(e.target).val(),$(e.target).attr("data-list"));
        }
    },
    /**
     * 改变搜索输入框的值
     * @return {XML}
     */
    onChangQueryInput: function (e) {
        if(this.state.droupName == "商家名称"){
            var val = $(e.target).val();
            if(val != ""){
                this.schoolArray(val,$(e.target).attr("data-list"));
            }else{
                $("."+$(e.target).attr("data-list")+"").hide();
            }
        }
    },
    /**
     * 排序
     * @param val
     * @param cls
     */
    schoolArray: function (val,cls) {
        var businessDataList = [];
        for(var i = 0;i < this.state.businessDataAll.length;i++){
            if((this.state.businessDataAll[i].name).indexOf(val) >= 0){
                businessDataList.push({name:this.state.businessDataAll[i].name});
            }
        }
        if(businessDataList.length == 0){
            $("."+cls+"").hide();
        }else{
            $("."+cls+"").show();
            this.setState({businessDataList:businessDataList});
        }
    },
    /**
     *点击商家名称搜索输入框
     */
    onClickBar: function (name) {
        $("#businessQuery").val(name);
        this.setNavigation('搜索结果');
        this.getBusinessTableDate(1,this.state.menuType,this.state.droupName);
    },

    /**
     * 关闭图片
     * @param type 多个上传是区分作用 _logo后缀 商家logo图片 _busLi 商家营业执照 _busHeader商家头图  _header 商品图片头图 _goodsDetails 商品图片详情图 _coupon 商品优惠券图片
     * @returns {XML}
     */
    closeImg: function(type){
        document.querySelector('#file'+type+'').value = '';
        this.setImgData(type);
    },
    /**
     * 设置上传图片相关数据
     * @param type 多个上传是区分作用 _logo后缀 商家logo图片 _busLi 商家营业执照 _busHeader商家头图 _header 商品图片头图 _goodsDetails 商品图片详情图 _coupon 商品优惠券图片
     * @returns {XML}
     */
    setImgData: function (type) {
        if(type=='_logo'){
            this.changeImgData(0,{ updateImg: true,showImg: false,imgUrl:''});
        }else if(type=='_busLi'){
            this.changeImgData(1,{ updateImg: true,showImg: false,imgUrl:''});
        }else if(type=='_header'){
            this.changeImgData(2,{ updateImg: true,showImg: false,imgUrl:''});
        }else if(type=='_goodsDetails'){
            this.changeImgData(3,{ updateImg: true,showImg: false,imgUrl:''});
        }else if(type=='_coupon'){
            this.changeImgData(4,{ updateImg: true,showImg: false,imgUrl:''});
        }else if(type=='_busHeader'){
            this.changeImgData(5,{ updateImg: true,showImg: false,imgUrl:''});
        }else{
            this.state.imgData = [
                { updateImg: true,showImg: false,imgUrl:''},
                { updateImg: true,showImg: false,imgUrl:''},
                { updateImg: true,showImg: false,imgUrl:''},
                { updateImg: true,showImg: false,imgUrl:''},
                {updateImg: true,showImg: false,imgUrl:''},
                {updateImg: true,showImg: false,imgUrl:''}
            ];
            this.setState({imgData:this.state.imgData});
        }
    },
    /**
     * 加载图片
     * @param type 多个上传是区分作用 _logo后缀 商家logo图片 _busLi 商家营业执照 _busHeader 商家头图 _header 商品图片头图 _goodsDetails 商品图片详情图 _coupon 商品优惠券图片
     * @returns {XML}
     */
    imgLoad: function (type) {
        new Viewer(document.querySelector('#showImg'+type+''));//调用图片
    },
    /**
     * 选择图片
     * @param type 多个上传是区分作用 _logo后缀 商家logo图片 _busLi 商家营业执照 _busHeader 商家头图 _header 商品图片头图 _goodsDetails 商品图片详情图 _coupon 商品优惠券图片
     */
    onChangFile: function (type) {
        var fileUrl = $("#file"+type+"").val().split('\\');//注split可以用字符或字符串分割
        var fileName = fileUrl[fileUrl.length-1];//这就是要取得的图片名称
        var fileLat = fileName.substring( fileName.lastIndexOf('.')+1 );//后缀名称
        if(fileLat == "png" || fileLat == "jpg" || fileLat == "gif" || fileLat == "svg"){
            suixun.getImgInfo('file'+type+'',function (imgInfo) {
                if(imgInfo.size>5*1024*1024){
                    suixun.alert("图片不能大于5M！");
                    // }else if(imgInfo.width!=imgInfo.height){
                    //     suixun.alert("图片格式不对！");
                }else{
                    if(type=='_logo'){
                        if(imgInfo.width!=200||imgInfo.height!=200){
                            suixun.alert("商家logo图片格式不对！");
                            return;
                        }
                        this.state.imgData[0].showImg = true;
                        this.state.imgData[0].updateImg = true;
                        this.state.imgData[0].imgUrl = imgInfo.src;
                    }else if(type=='_busHeader'){
                        if(imgInfo.width!=750||imgInfo.height!=420){
                            suixun.alert("商家头图格式不对！");
                            return;
                        }
                        this.state.imgData[5].showImg = true;
                        this.state.imgData[5].updateImg = true;
                        this.state.imgData[5].imgUrl = imgInfo.src;
                    }else if(type=='_busLi'){
                        this.state.imgData[1].showImg = true;
                        this.state.imgData[1].updateImg = true;
                        this.state.imgData[1].imgUrl = imgInfo.src;
                    }else if(type=='_header'){
                        if(imgInfo.width!=200||imgInfo.height!=200){
                            suixun.alert("商品图片头图格式不对！");
                            return;
                        }
                        this.state.imgData[2].showImg = true;
                        this.state.imgData[2].updateImg = true;
                        this.state.imgData[2].imgUrl = imgInfo.src;
                    }else if(type=='_goodsDetails'){
                        if(imgInfo.width!=750||imgInfo.height!=300){
                            suixun.alert("商品图片详情图格式不对！");
                            return;
                        }
                        this.state.imgData[3].showImg = true;
                        this.state.imgData[3].updateImg = true;
                        this.state.imgData[3].imgUrl = imgInfo.src;
                    }else if(type=='_coupon'){
                        if(imgInfo.width!=500||imgInfo.height!=130){
                            suixun.alert("商品优惠券图格式不对！");
                            return;
                        }
                        this.state.imgData[4].showImg = true;
                        this.state.imgData[4].updateImg = true;
                        this.state.imgData[4].imgUrl = imgInfo.src;
                    }
                    this.setState({imgData:this.state.imgData});
                }
            }.bind(this));
        }else{
            suixun.alert("请选择图片文件上传!",function (data) {
                if(data){
                    $("#file"+type+"").val("");
                    if(type=='_logo'){
                        this.state.imgData[0].showImg = false;
                        this.state.imgData[0].imgUrl = '';
                    }else if(type=='_busLi'){
                        this.state.imgData[1].showImg = false;
                        this.state.imgData[1].imgUrl = '';
                    }else if(type=='_busHeader'){
                        this.state.imgData[5].showImg = false;
                        this.state.imgData[5].imgUrl = '';
                    }else if(type=='_header'){
                        this.state.imgData[2].showImg = false;
                        this.state.imgData[2].imgUrl = '';
                    }else if(type=='_goodsDetails'){
                        this.state.imgData[3].showImg = false;
                        this.state.imgData[3].imgUrl = '';
                    }else if(type=='_coupon'){
                        this.state.imgData[4].showImg = false;
                        this.state.imgData[4].imgUrl = '';
                    }
                    this.setState({imgData:this.state.imgData});
                }
            }.bind(this));
        }
    },


    /**
     * 商家列表——编辑商家
     * @param trData  表单一行的数据
     * @returns {XML}
     */
    onClickEdit: function (trData) {
        this.getCompanyDetails(trData.id,'编辑商家');
    },
    /**
     * 商家列表——商家详情
     * @param type  true商家列表 false商家审核
     * @param trData  表单一行的数据
     * @returns {XML}
     */
    busDetails: function (type,trData) {
        this.getCompanyDetails(trData.id,'商家详情');
    },
    /**
     * 获取商家详情
     * @param companyid 商家的ID
     * @param navigation 导航的名称
     */
    getCompanyDetails: function (companyid,navigation) {
        suixun.showLoding();//显示加载中
        suixun.ajax(serverUrl+'/credits/company/find_one_company.json?companyid='+companyid,'',"get",function(data){
            suixun.hideLoding();//隐藏加载中
            if(data.code == 200){
                if(data.info){
                    //已选地区--组装数据
                    if(navigation=='编辑商家'){
                        var addressData = this.state.addressData;
                        addressData = [];
                        var intentArea = data.info.data.intentArea;
                        console.log(intentArea);
                        if(intentArea.indexOf('&')>-1){
                            intentArea = intentArea.substring(0,intentArea.length-1);
                        }
                        intentArea = intentArea.replace(/&/g,',');//.replace(/,/g,' ')
                        for(var j = 0;j<intentArea.split(',').length;j++){
                            var province = intentArea.split(',')[j].split(' ')[0];
                            var city = intentArea.split(',')[j].split(' ')[1];
                            var town = intentArea.split(',')[j].split(' ')[2];
                            addressData.push({
                                id:j,
                                province:province==undefined?'':province,
                                city:city==undefined?'':city,
                                town:town==undefined?'':town,
                            });
                        }
                        $('#busiName').val(data.info.data.name);//商户名
                        var businessType = data.info.data.businessType;
                        if(businessType !='餐饮美食' && businessType !='亲子旅游' && businessType !='教育培训' && businessType !='运动健身' && businessType !='休闲娱乐' && businessType !='医疗健康'){
                            $('#operateType').val('其他');//经营类别
                            $('#operateTypeOther').val(businessType);//经营类别——其他
                            this.state.operateType = '其他';
                        }else{
                            $('#operateType').val(businessType);//经营类别
                            this.state.operateType = businessType;
                        }
                        $('#busiUserName').val(data.info.data.linkPeople);//联系人
                        $('#busiUserTitle').val(data.info.data.linkPeopleJob);//联系人职称
                        $('#busiUserPhone').val(data.info.data.linkPhone);//联系人电话
                        $('#busiLoginAccount').val(data.info.data.account);//登录账号
                        $('#busiGoodsNumber').val(data.info.data.goodsShowNum);//商品限制个数
                        $('#businessScore').val(data.info.data.level);//商家评分
                        // $('#busiTintroduce').val(data.info.data.introduce);//商家介绍
                        BusUE.ready(function() {//编辑器初始化完成再赋值
                            console.log(decodeURIComponent(data.info.data.introduce));
                            BusUE.setContent(decodeURIComponent(data.info.data.introduce));  //赋值给UEditor
                        });
                        data.info.data.address = data.info.data.address.replace(/,/g,'-').replace(/&/g,'-');//h5上传的数据格式
                        //商家地址、合作意向区域
                        $('.span-provinceid1').text(data.info.data.address.split('-')[0]);//省
                        $('.span-cityid1').text(data.info.data.address.split('-')[1]);//市
                        $('.span-countyid1').text(data.info.data.address.split('-')[2]);//区
                        $('#adressDetails').val(data.info.data.address.split('-')[3]);//
                        if(data.info.data.address.split('-').length>4){
                            $('#adressDetailsInfo').html(data.info.data.address.split('-')[4]+','+data.info.data.address.split('-')[5]);//
                        }else{
                            $('#adressDetailsInfo').html('104.06585, 30.657361');//四川省成都市青羊区天府广场
                        }
                        // this.state.imgData[0] = { updateImg: false,showImg: true,imgUrl:data.info.data.logo};
                        // this.state.imgData[1] = { updateImg: false,showImg: true,imgUrl:data.info.data.businessLicence};
                        this.changeImgData(0,{ updateImg: false,showImg: true,imgUrl:data.info.data.logo});
                        this.changeImgData(5,{ updateImg: false,showImg: true,imgUrl:data.info.data.companyImgs});
                        this.changeImgData(1,{ updateImg: false,showImg: true,imgUrl:data.info.data.businessLicence});
                        this.setState({busTrData:data.info.data,addressData:addressData,operateType: this.state.operateType});
                    }else{
                        BusUE.ready(function() {//编辑器初始化完成再赋值
                            BusUE.setContent(decodeURIComponent(data.info.data.introduce));  //赋值给UEditor
                        });
                        this.changeImgData(0,{ updateImg: false,showImg: true,imgUrl:data.info.data.logo});
                        this.changeImgData(5,{ updateImg: false,showImg: true,imgUrl:data.info.data.companyImgs});
                        this.changeImgData(1,{ updateImg: false,showImg: true,imgUrl:data.info.data.businessLicence});
                        this.setState({busTrData:data.info.data});
                    }
                }
                this.setNavigation(navigation);
            }else{
                suixun.alert(data.msg);
            }
        }.bind(this));
    },
    /**
     * 编辑、查看详情的时候设置imgData
     * @param index
     * @param data
     */
    changeImgData: function (index, data) {
        this.state.imgData[index] = data;
        this.setState({imgData:this.state.imgData});
    },
    /**
     * 商家审核——审核通过、审核不通过
     * @param type  true审核通过 反之
     * @param trData  表单一行的数据
     * @returns {XML}
     */
    busExaExamine: function (type,trData) {
        var title = '是否确定通过该商家审？';
        if(!type){
            title = '是否确定不通过该商家审？';
        }
        suixun.confirm_noTit(title, function (data) {
            if(data){
                var data = new FormData();
                data.append("isPass",type);
                if(this.state.navigation!=''){
                    var busiOpinion = $("#busiOpinion").val();
                    if(busiOpinion==''){
                        data.append("opinion",type?'通过':'不通过');
                    //     setTimeout(function () {
                    //         suixun.alert('审核意见不能为空！');
                    //     },1);
                    //     return;
                    }else{
                        data.append("opinion",busiOpinion);
                    }

                }else{
                    data.append("opinion",type?'通过':'不通过');
                }
                data.append("companyid",trData.id);
                suixun.showLoding();//显示加载中
                suixun.ajax(serverUrl+'/credits/company/audit_company.json',data,"post",function(data){
                    suixun.hideLoding();//隐藏加载中
                    if(data.code == 200){
                        suixun.alert('操作成功!',function (data) {
                            if(data){
                                this.onPageClick(currentpage);
                                this.setNavigation('');//设置导航为空 “商家审核>商家详情”这种状态是使用
                            }
                        }.bind(this));
                    }else{
                        suixun.alert(data.msg);
                    }
                }.bind(this));
            }
        }.bind(this));
    },
    /**
     * 修改——经营类别下拉框
     * @return {XML}
     */
    operateTypeChange: function () {
        this.setState({operateType: $('#operateType option:selected').val()});
    },
    /**
     * 新增地址
     */
    addAdress: function () {
        var province = $('.span-provinceid2').text();//省
        var city = $('.span-cityid2').text();//市
        var county = $('.span-countyid2').text();//区
        var id = 0,addressData = this.state.addressData;
        if(province=="选择省份"){
            suixun.alert('请选择省份');
            return;
        }
        province = province=="选择省份"?"":province;
        city = city=="选择地区"?"":city;
        county = county=="选择县或街道"?"":county;
        if(addressData.length>0){
            id = addressData[addressData.length-1].id+1;
        }
        var isRepeat = false;
        for(var j = 0;j < addressData.length;j++){
            if(addressData[j].province == province){
                if(addressData[j].city == city && city != ''){
                    if(addressData[j].town == county && county != ''){
                        isRepeat = true;
                        break;
                    }else if((county == '' && addressData[j].town == '') || (county != '' && addressData[j].town == '') || (county == '' && addressData[j].town != '')){
                        isRepeat = true;
                        break;
                    }
                }else if((city == '' && addressData[j].city=='') || (city != '' && addressData[j].city == '') || (city == '' && addressData[j].city != '')){
                    isRepeat = true;
                    break;
                }
            }
        }
        if(isRepeat){
            suixun.alert('已有该地区！');
            return;
        }
        addressData.push({
            id:id,
            province:province,
            city:city,
            town:county,
        });
        this.setState({addressData:addressData});
    },
    /**
     * 清除指定地址
     */
    closeAddres: function (index) {
        if(this.state.addressData.length==1){
            this.state.addressData = [];
        }else{
            this.state.addressData.splice(index,1);
        }
        this.setState({addressData:this.state.addressData});
    },
    /**
     * 设置商家地址是否显示 是否选择全国 商品使用对象家长或者老师
     * @param key 设置的值
     */
    setAddressOrType: function (key) {
        this.state.addressOrType[key] = !this.state.addressOrType[key];
        this.setState({addressOrType:this.state.addressOrType});
    },
    /**
     * 设置商家地址是否显示 是否选择全国 商品使用对象家长或者老师
     * @param value 设置的值
     */
    setGoodsTrData: function (value) {
        this.setState({goodsTrData:value});
    },
    /**
     * 设置商家地址是否显示 是否选择全国 商品使用对象家长或者老师
     * @param value 设置的值
     */
    setAddressOrTypeAll: function (value) {
        this.setState({addressOrType:value});
    },
    /**
     * 新增商品
     * @param trData
     */
    addBusGoods: function (trData) {
        var addressOrType = {
            isShowAddress: true,//是否显示商家地址
            parent: false,//是否家长
            teacher: false,//是否老师
            china: false,//是否显示省市区
        };
        this.getCompanyDetails(trData.id,'商家详情>新增商品');
        this.setNavigation('商家详情>新增商品');
        this.setAddressOrTypeAll(addressOrType);
    },
    /**
     * 设置套餐价格参数
     * @param index
     * @param type name number price
     * @param element
     */
    setGoodsPackage: function (index, type, element) {
        let goodsPackageData = this.state.goodsPackageData;
        let value = element.target.value;
        if((type == 'price' && !/^\d+\.?\d{0,2}$/.test(value)) || (type == 'number' && !/^[0-9]*[1-9][0-9]*$/.test(value))){
            value = goodsPackageData[index][type]
        }
        goodsPackageData[index][type] = value;
        this.setState({goodsPackageData:goodsPackageData})
    },
    /**
     * 添加一个设备套餐
     */
    addGoodsPackage: function () {
        let goodsPackageData = this.state.goodsPackageData;
        goodsPackageData.push({
            name:'',
            number: '',
            price: '',
        });
        this.setState({goodsPackageData:goodsPackageData})
    },
    /**
     * 删除一个设备套餐
     */
    deleteGoodsPackage: function (index) {
        let goodsPackageData = this.state.goodsPackageData;
        if(goodsPackageData.length == 1){
            goodsPackageData = [];
        }else{
            goodsPackageData.splice(index, 1);
        }
        this.setState({goodsPackageData:goodsPackageData})
    },
    /**
     * 修改state
     * @param obj
     */
    setSta: function (obj) {
      this.setState(obj)
    },
    /**
     * 商家是否置顶
     * true取消置顶，false置顶
     * 和商家的取消置顶是反的
     * @param trData
     * @return {XML}
     */
    setGoodsIsTop: function (trData) {
        let svar = this;
        suixun.confirm_noTit(trData.isTop?'是否取消置顶？':'是否置顶？',function (isOk) {
            if(isOk){
                suixun.showLoding();//显示加载中
                suixun.ajax(serverUrl+'/credits/company/updateTop?id='+trData.id+'&isCancel='+trData.isTop,'','get',function (data) {
                    if(data){
                        suixun.hideLoding();//隐藏加载中
                        if(data.code == 200){
                            suixun.alert('操作成功!',function (data) {
                                if(data){
                                    svar.setNavigation('');
                                    svar.onPageClick(currentpage);
                                }
                            });
                        }else{
                            suixun.alert(data.msg);
                        }
                    }
                });
            }
        })
    },
    /**
     * 显示地图层
     */
    onClickHidePop: function () {
        $(".initializeMenu", window.parent.document).hide();//父页面的遮罩
        $(".popModel").hide();
        if(posiResult.regeocode == undefined){
            $("#queryAddressInput").val('');
        }
    },
    /**
     * 确定详情地址
     * @return {XML}
     */
    isOKAddress: function () {
        let provinceid1 = $('.span-provinceid1').text();//省
        let cityid1 = $('.span-cityid1').text();//市
        let countyid1 = $('.span-countyid1').text();//区
        let queryAddressInput = $('#queryAddressInput').val();//详细地址
        if(provinceid1==cityid1){
            cityid1 = '';
        }
        if(queryAddressInput == ''|| posiResult.regeocode == undefined){
            suixun.alert('请选择'+provinceid1+cityid1+countyid1+'下地址');
            return;
        }
        let pro = posiResult.regeocode.addressComponent.province,
            city = posiResult.regeocode.addressComponent.city,
            district = posiResult.regeocode.addressComponent.district;
        if(provinceid1 != pro || cityid1 != city || (countyid1 != district && countyid1 != '其他')){
            suixun.alert('请选择'+provinceid1+cityid1+countyid1+'下地址');
            return;
        }
        $("#adressDetails").val(queryAddressInput.replace(pro,'').replace(city,'').replace(district,''));
        this.onClickHidePop();
    },
    render: function () {
        {
            /**
             * 商家管理、商家审核数据
             */
            var Tabels =  '',busTrData = this.state.busTrData;
            if(this.state.menuType==1){//商家管理
                Tabels = this.state.tableData.map(function (data,index) {
                    return (
                        <tr>
                            <td style={{width: '5%'}}>{index+1}</td>
                            <td style={{width: '25%'}}>{data.name}</td>
                            <td style={{width: '25%'}}>{data.phone}</td>
                            <td style={{width: '25%'}}>{data.createTime}</td>
                            <td style={{width: '30%'}}>
                                <div className='trButton trLeft trButton' onClick={this.onClickEdit.bind(this,data)}>编辑</div>
                                <div className='trButton trLeft table-select' onClick={this.busDetails.bind(this,true,data)}>详情</div>
                                {
                                    data.isTop?
                                        <div className="trButton trLeft table-select trLong" onClick={this.setGoodsIsTop.bind(this, data)} >取消置顶</div>
                                        :
                                        <div className="trButton trLeft table-select" onClick={this.setGoodsIsTop.bind(this, data)} >置顶</div>
                                }
                                <div className='trButton trLeft table-select trLong ' onClick={this.addBusGoods.bind(this,data)} >新增商品</div>
                            </td>
                        </tr>
                    )
                }.bind(this));
            }else{//商家审核
                Tabels = this.state.busExaTableData.map(function (data,index) {
                    return (
                        <tr>
                            <td style={{width: '5%'}}>{index+1}</td>
                            <td style={{width: '25%'}}>{data.name}</td>
                            <td style={{width: '25%'}}>{data.phone}</td>
                            <td style={{width: '25%'}}>{data.createTime}</td>
                            <td style={{width: '30%'}}>
                                <div className='trButton trLeft table-select' onClick={this.busDetails.bind(this,false,data)}>详情</div>
                                <div className='trButton trLeft trButton trLong ' onClick={this.busExaExamine.bind(this,true,data)}>审核通过</div>
                                <div className='trButton trLeft table-delete trLong ' onClick={this.busExaExamine.bind(this,false,data)}>审核不通过</div>
                            </td>
                        </tr>
                    )
                }.bind(this));
            }
        }
        var queryDateLists = this.state.businessDataList.map(function (data) {
            return (
                <span className="businessNameList-value schoolList-value" onClick={this.onClickBar.bind(this,data.name)}>{data.name}</span>
            )
        }.bind(this));
        return (
            <div className="tableManage-body">
                <header>
                    <div className="header-left" style={this.state.navigation==''?{display:'none'}:{display:'block'}}>
                        <div style={this.state.navigation!=''?{display:'none'}:{display:'block'}} className='navigation'>{this.state.menuType==1?'商家管理':'商家审核'}</div>
                        <div style={this.state.navigation==''?{display:'none'}:{display:'block'}} className='navigation selsect' >
                            <a href="javascript:void(0);" onClick={this.setNavigation.bind(this,'')}>{this.state.menuType==1?'商家管理':'商家审核'}</a><span>>
                            {
                                this.state.navigation.indexOf('>')>-1?
                                    <span>
                                        <a href="javascript:void(0);" onClick={this.setNavigation.bind(this,'商家详情')}>商家详情</a>
                                        <span>>
                                            {
                                                //商家详情>新增商品>使用情况
                                                this.state.navigation.substring(5,this.state.navigation.length).indexOf('>')>-1?
                                                    <span>
                                                        <a href="javascript:void(0);" onClick={this.setNavigation.bind(this,'商家详情>商品详情')}>商品详情</a>
                                                        <span>>使用情况</span>
                                                    </span>
                                                    :
                                                    this.state.navigation.split('>')[1]
                                            }
                                            </span>
                                    </span>
                                    :
                                    this.state.navigation
                            }
                            </span>
                        </div>
                    </div>
                    <div className="header-left"  style={this.state.navigation!=''?{display:'none'}:{display:'block'}}>
                        <div className="header-left-studentInfo">
                            <span className={this.state.menuType==1?"header-left-button menu-width showOrder ":"header-left-button menu-width "} onClick={this.changeMenu.bind(this,1)}>商家列表</span>
                            <span className={this.state.menuType==2?"header-left-button showOrder ":"header-left-button "} onClick={this.changeMenu.bind(this,2)}>商家审核</span>
                        </div>
                    </div>
                    <div className="header-right" style={this.state.navigation!=''?this.state.navigation.indexOf('搜索结果')>-1?{display:'block'}:{display:'none'}:{display:'block'}}>
                        <div className="header-right-select droup-select droup-type" >
                            <div className="school-or-table school-or-parent">{this.state.droupName}</div>
                            <span className="lower-right-corner"/>
                            <div className="drop-down left-drop-down" >
                                <span className="select-value school-name" onClick={this.setDroup.bind(this,'商家名称')}>商家名称</span>
                                <span className="select-value school-name" onClick={this.setDroup.bind(this,'商家手机号')}>商家手机号</span>
                                <span className="select-value school-name" onClick={this.setDroup.bind(this,'区域')}>区域</span>
                                <span className="select-value school-name" onClick={this.setDroup.bind(this,'经营类别')}>经营类别</span>
                            </div>
                        </div>
                        <div className="header-query retrieval">
                            <div className="header-query-input">
                                <input className="query-value enterEvent" type="text" id="businessQuery" data-list="queryDateList" onChange={this.onChangQueryInput} onClick={this.onClickQueryInput}  maxLength={this.state.droupName=='商家名称'?"50":"11"} placeholder={"请输入"+this.state.droupName+'关键字搜索'}/>
                            </div>
                            <div className="header-query-img"  onClick={this.setNavigation.bind(this,'搜索结果')}/>
                            <div className="schoolList businessList queryDateList" data-inputId="businessQuery">
                                {queryDateLists}
                            </div>
                        </div>
                        <div className="header-right-botton" onClick={this.setNavigation.bind(this,'新建商家')}>新建商家</div>
                    </div>
                </header>

                {
                    /**
                     * 新增商家、编辑商家、商家详情
                     */
                }
                <div className="body-updateAttendance" style={this.state.navigation=='新建商家'?{display:'block'}:this.state.navigation=='编辑商家'?{display:'block'}:this.state.navigation=='商家详情'?{display:'block'}:{display:'none'}}>
                    <div className="body-content">
                        <div className="body-content-title">商&nbsp;&nbsp;家&nbsp;&nbsp;名：</div>
                        <div className="body-content-text">
                            {
                                this.state.navigation=='商家详情'?
                                    <div className="content-border element-content noBorder textInput" >{busTrData.name}</div>
                                    :
                                    <div className="content-border">
                                        <input type="text" id="busiName" className="input-content" placeholder="请填写商家名" maxLength="32"/>
                                    </div>
                            }

                        </div>
                    </div>
                    <div className="body-content" >
                        <div className="body-content-title">经营类别：</div>
                        <div className="body-content-text">
                            {
                                this.state.navigation=='商家详情'?
                                    <div className="content-border element-content noBorder textInput" >{busTrData.businessType}</div>
                                    :
                                    <div className="content-select-border">
                                        <select className="export-factory msgType " id="operateType" selected={this.state.operateType} onChange={this.operateTypeChange.bind(this)}>
                                            {/*餐饮美食、亲子旅游、教育培训、运动健身、医疗健康、休闲娱乐、其他*/}
                                            <option value="餐饮美食" >餐饮美食</option>
                                            <option value="亲子旅游" >亲子旅游</option>
                                            <option value="教育培训" >教育培训</option>
                                            <option value="运动健身" >运动健身</option>
                                            <option value="医疗健康" >医疗健康</option>
                                            <option value="休闲娱乐" >休闲娱乐</option>
                                            <option value="其他" >其他</option>
                                        </select>
                                    </div>
                            }

                        </div>
                        <div className="body-content" style={{width:'520px',float:'left',margin:'-36px 0 0 400px',display:this.state.operateType=='其他'?'block':'none'}}>
                            <div className="body-content-title">其&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;他：</div>
                            <div className="body-content-text">
                                <div className="content-border">
                                    <input type="text" id="operateTypeOther" className="input-content" placeholder="请输入经营类别" maxLength="10"/>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div className="body-content">
                        <div className="body-content-title">联&nbsp;&nbsp;系&nbsp;&nbsp;人：</div>
                        <div className="body-content-text">
                            {
                                this.state.navigation=='商家详情'?
                                    <div className="content-border element-content noBorder textInput" >{busTrData.linkPeople}</div>
                                    :
                                    <div className="content-border">
                                        <input type="text" id="busiUserName" className="input-content" placeholder="请填写联系人" maxLength="20"/>
                                    </div>
                            }
                        </div>
                    </div>
                    <div className="body-content">
                        <div className="body-content-title" style={{backgroundPosition:'80px 4px'}}>联系人职务：</div>
                        <div className="body-content-text">
                            {
                                this.state.navigation == '商家详情' ?
                                    <div className="content-border element-content noBorder textInput">{busTrData.linkPeopleJob}</div>
                                    :
                                    <div className="content-border">
                                        <input type="text" id="busiUserTitle" className="input-content" placeholder="请填写联系人职务" maxLength="20"/>
                                    </div>
                            }
                        </div>
                    </div>
                    <div className="body-content">
                        <div className="body-content-title">联系电话：</div>
                        <div className="body-content-text">
                            {
                                this.state.navigation=='商家详情'?
                                    <div className="content-border element-content noBorder textInput" >{busTrData.linkPhone}</div>
                                    :
                                    <div className="content-border">
                                        <input type="text" id="busiUserPhone" className="input-content" placeholder="请填写联系电话" maxLength="15"/>
                                    </div>
                            }
                        </div>
                    </div>
                    <div className="body-content">
                        <div className="body-content-title noImg"  style={{width:'120px',backgroundPosition:'92px 4px'}}>商品限制个数：</div>
                        <div className="body-content-text">
                            {
                                this.state.navigation=='商家详情'?
                                    <div className="content-border element-content noBorder textInput" >{busTrData.goodsShowNum}</div>
                                    :
                                    <div className="content-select-border">
                                        <select className="export-factory msgType " selected={busTrData.goodsShowNum} id="busiGoodsNumber">
                                            {/*<option value="0" >0</option>*/}
                                            <option value="1" >1</option>
                                            <option value="2" selected='selected'>2</option>
                                        </select>
                                    </div>
                            }
                        </div>
                    </div>
                    <div className="body-content" >
                        <div className="body-content-title noImg">商家评分：</div>
                        <div className="body-content-text">
                            {
                                this.state.navigation=='商家详情'?
                                    <div className="content-border element-content noBorder textInput" >
                                        {
                                            busTrData.level==0?'不设置':
                                                busTrData.level==1?'一颗心':
                                                    busTrData.level==2?'二颗心':
                                                    busTrData.level==3?'三颗心':
                                                        busTrData.level==4?'四颗心':
                                                            busTrData.level==5?'五颗心':'不设置'
                                        }
                                    </div>
                                    :
                                    <div className="content-select-border">
                                        <select className="export-factory msgType " selected={busTrData.level} id="businessScore">
                                            <option value="0" >不设置</option>
                                            <option value="1" >一颗心</option>
                                            <option value="2" >二颗心</option>
                                            <option value="3" >三颗心</option>
                                            <option value="4" >四颗心</option>
                                            <option value="5" >五颗心</option>
                                        </select>
                                    </div>
                            }
                        </div>
                    </div>
                    {
                        /**
                         * 商家地址
                         */
                    }
                    {
                        this.state.navigation=='商家详情'?
                            <div className="body-content">
                                <div className="body-content-title">商家地址：</div>
                                <div className="body-content-text">
                                    <div className="content-border element-content noBorder textInput" >
                                        {
                                            busTrData.address.replace(/,/g,'-').replace(/&/g,'-').split('-').map(function(value, index){
                                                return(
                                                    index<3?value+'-':index==3?value:''
                                                )
                                            })
                                        }
                                        </div>
                                </div>
                            </div>
                            :
                            <Address id="1" type='商家地址' zIndex="1001" busTrData={this.state.busTrData} navigation={this.state.navigation} />
                    }
                    {
                        /**
                         * 合作意向区域
                         */
                    }

                    {
                        this.state.navigation=='商家详情'?
                            <div className="body-content">
                                <div className="body-content-title" style={{width:'120px',backgroundPosition:'92px 4px'}}>合作意向区域：</div>
                                <div className="body-content-text">
                                    <div className="content-border element-content noBorder " style={{height:'auto',minHeight:'30px',wordWrap: 'break-word'}} >{busTrData.intentArea.substring(0,busTrData.intentArea.length-1).replace(/,/g,' ').replace(/&/g,',')}</div>
                                </div>
                            </div>
                            :
                            <Address id="2" type="合作意向区域" zIndex="1000" addAdress={this.addAdress} />
                    }
                    {
                        this.state.navigation=='商家详情'?
                            '':
                            <div className="body-content">
                                {/*style={{width:'135px',backgroundPosition:'108px 4px'}}*/}
                                <div className="body-content-title" >已选地区：</div>
                                <div className="body-content-text">
                                    <div className="content-border element-content noBorder" style={{height:'auto',width:'900px'}}>
                                        {
                                            this.state.addressData.length>0?
                                                this.state.addressData.map(function (data,index) {
                                                    return (
                                                        <div className="text-block">
                                                            <span className="content">{data.province}&nbsp;{data.city}&nbsp;{data.town}</span>
                                                            <span className="colose-img" onClick={this.closeAddres.bind(this,index)}/>
                                                        </div>
                                                    )
                                                }.bind(this)):<span style={{color:'#999999'}}>请选择地区！</span>
                                        }
                                    </div>
                                </div>
                            </div>
                    }

                    <div className="body-content">
                        <div className="body-content-title">登录账号：</div>
                        <div className="body-content-text">
                            {
                                this.state.navigation=='商家详情'?
                                    <div className="content-border element-content noBorder textInput" >{busTrData.account}</div>
                                    :
                                    <div className="content-border ">
                                        <input type="text" id="busiLoginAccount" className="input-content" placeholder="请填写登录账号" maxLength="11"/>
                                    </div>

                            }
                            {
                                this.state.navigation=='商家详情'?'':<span className="remarks" >说明：请输入手机号，密码默认为手机号</span>
                            }

                        </div>
                    </div>
                    <div className="body-content">
                        <div className="body-content-title" style={{backgroundPosition: '64px 3px'}}>商家logo：</div>
                        <div className="body-content-text content-file">
                            <form name="excelInputForm" className="input-from excelInputFrom" id="excelInputFrom_logo" method="post"  style={{display:this.state.navigation=='商家详情'?'none':'block'}}>
                                <input type="hidden" className="input-fileImg" name="filename"  />
                                <a href="javascript:;" className="file">
                                    上传图片
                                    <input type="file" name="file" onChange={this.onChangFile.bind(this,'_logo')}  accept="image/gif,image/jpeg,image/jpg,image/png,image/svg" id="file_logo" />
                                </a>
                            </form>
                            {
                                this.state.imgData[0].showImg==true?
                                    <div className="upload-show-img">
                                        {
                                            this.state.navigation=='商家详情'?'':<span onClick={this.closeImg.bind(this,'_logo')}/>
                                        }

                                        <lable className={this.state.navigation=='新建商家'?'':'border'}><img onLoad={this.imgLoad.bind(this,'_logo')} src={this.state.imgData[0].imgUrl} id="showImg_logo" onError={this.defaultImg.bind(this)} /></lable>
                                    </div>:''
                            }
                            <span className="inputFile-remarks"  style={{display:this.state.navigation=='商家详情'?'none':'block'}}>说明：用于商家列表展示图片,尺寸为：宽200*高200px,大小限制5M</span>
                        </div>
                    </div>
                    <div className="body-content">
                        <div className="body-content-title" style={{backgroundPosition: '64px 3px'}}>商家头图：</div>
                        <div className="body-content-text content-file">
                            <form name="excelInputForm" className="input-from excelInputFrom" id="excelInputFrom_busHeader" method="post"  style={{display:this.state.navigation=='商家详情'?'none':'block'}}>
                                <input type="hidden" className="input-fileImg" name="filename"  />
                                <a href="javascript:;" className="file">
                                    上传图片
                                    <input type="file" name="file" onChange={this.onChangFile.bind(this,'_busHeader')}  accept="image/gif,image/jpeg,image/jpg,image/png,image/svg" id="file_busHeader" />
                                </a>
                            </form>
                            {
                                this.state.imgData[5].showImg==true?
                                    <div className="upload-show-img">
                                        {
                                            this.state.navigation=='商家详情'?'':<span onClick={this.closeImg.bind(this,'_busHeader')}/>
                                        }

                                        <lable className={this.state.navigation=='新建商家'?'':'border'}><img onLoad={this.imgLoad.bind(this,'_busHeader')} src={this.state.imgData[5].imgUrl} id="showImg_busHeader" onError={this.defaultImg.bind(this)} /></lable>
                                    </div>:''
                            }
                            <span className="inputFile-remarks"  style={{display:this.state.navigation=='商家详情'?'none':'block'}}>说明：用于商家详情、商家介绍页头部图片展示,尺寸为：宽750*高420px,大小限制5M</span>
                        </div>
                    </div>
                    <div className="body-content">
                        <div className="body-content-title" style={{backgroundPosition: '64px 3px'}}>营业执照：</div>
                        <div className="body-content-text content-file">
                            <form name="excelInputForm" className="input-from excelInputFrom" id="excelInputFrom_busLi" method="post" style={{display:this.state.navigation=='商家详情'?'none':'block'}}>
                                <input type="hidden" className="input-fileImg" name="filename"  />
                                <a href="javascript:void(0);" className="file">
                                    上传图片
                                    <input type="file" name="file" onChange={this.onChangFile.bind(this,'_busLi')}  accept="image/gif,image/jpeg,image/jpg,image/png,image/svg" id="file_busLi" />
                                </a>
                            </form>
                            {
                                this.state.imgData[1].showImg==true?
                                    <div className="upload-show-img">
                                        {
                                            this.state.navigation=='商家详情'?'':<span onClick={this.closeImg.bind(this,'_busLi')}/>
                                        }

                                        <lable className={this.state.navigation=='新建商家'?'':'border'}><img onLoad={this.imgLoad.bind(this,'_busLi')} src={this.state.imgData[1].imgUrl} id="showImg_busLi" onError={this.defaultImg.bind(this)} /></lable>
                                    </div>:''
                            }
                            <span className="inputFile-remarks"  style={{display:this.state.navigation=='商家详情'?'none':'block'}}>说明：大小限制5M</span>
                        </div>
                    </div>
                    <div className="body-content">
                        <div className="body-content-title ">商家介绍：</div>
                        <div className="body-content-text">
                            <script id="busiTintroduce" type="text/plain" />
                        </div>
                    </div>
                    {
                        this.state.navigation=='商家详情'?
                            this.state.menuType==2?
                                <div className="body-content">
                                    <div className="body-content-title noImg">审核意见：</div>
                                    <div className="body-content-text">
                                        <div className="content-border content-textarea">
                                            <textarea type="text" id="busiOpinion" className="textarea-content" placeholder="请填写审核意见" maxLength="200"/>
                                        </div>
                                    </div>
                                </div>
                                :
                                ''
                            :''
                    }

                    {
                        this.state.navigation=='商家详情'?
                            this.state.menuType==2?
                                <div className="body-content">
                                    <span className="body-svae" style={{marginLeft:'120px'}} onClick={this.busExaExamine.bind(this,true,busTrData)}>审核通过</span>
                                    <span className="body-svae" style={{marginLeft:'320px',background: 'rgb(259,89,89)'}} onClick={this.busExaExamine.bind(this,false,busTrData)}>审核不通过</span>
                                </div>
                                :
                                /**
                                 * 商品管理组件
                                 */
                                <GoodsManger
                                    busTrData={this.state.busTrData}
                                    otherData={this.state.otherData}
                                    goodsTableData={this.state.goodsTableData}
                                    goodsTrData={this.state.goodsTrData}
                                    addressOrType={this.state.addressOrType}
                                    imgData={this.state.imgData}
                                    useDetailsInfo={this.state.useDetailsInfo}
                                    useDetailsData={this.state.useDetailsData}
                                    goodsPackageData={this.state.goodsPackageData}
                                    navigation={this.state.navigation}
                                    changeImgData={this.changeImgData}
                                    setNavigation={this.setNavigation}
                                    onChangFile={this.onChangFile}
                                    closeImg={this.closeImg}
                                    imgLoad={this.imgLoad}
                                    defaultImg={this.defaultImg}
                                    goodsPageClick={this.onPageClick}
                                    setAddressOrType={this.setAddressOrType}
                                    setGoodsTrData={this.setGoodsTrData}
                                    setAddressOrTypeAll={this.setAddressOrTypeAll}
                                    setUseDetailsInfo={this.setUseDetailsInfo}
                                    setGoodsPackage={this.setGoodsPackage}
                                    addGoodsPackage={this.addGoodsPackage}
                                    deleteGoodsPackage={this.deleteGoodsPackage}
                                    setSta={this.setSta}
                                />

                            :
                            <div className="body-content">
                                <span className="body-svae" onClick={this.addBusiness.bind(this)}>保存</span>
                            </div>
                    }
                </div>
                {
                    this.state.navigation.indexOf('商家详情>')>-1?
                        /**
                         * 商品管理组件
                         */
                        <GoodsManger
                            busTrData={this.state.busTrData}
                            otherData={this.state.otherData}
                            goodsTableData={this.state.goodsTableData}
                            goodsTrData={this.state.goodsTrData}
                            addressOrType={this.state.addressOrType}
                            imgData={this.state.imgData}
                            useDetailsInfo={this.state.useDetailsInfo}
                            useDetailsData={this.state.useDetailsData}
                            goodsPackageData={this.state.goodsPackageData}
                            navigation={this.state.navigation}
                            changeImgData={this.changeImgData}
                            setNavigation={this.setNavigation}
                            onChangFile={this.onChangFile}
                            closeImg={this.closeImg}
                            imgLoad={this.imgLoad}
                            defaultImg={this.defaultImg}
                            goodsPageClick={this.onPageClick}
                            setAddressOrType={this.setAddressOrType}
                            setGoodsTrData={this.setGoodsTrData}
                            setAddressOrTypeAll={this.setAddressOrTypeAll}
                            setUseDetailsInfo={this.setUseDetailsInfo}
                            setGoodsPackage={this.setGoodsPackage}
                            addGoodsPackage={this.addGoodsPackage}
                            deleteGoodsPackage={this.deleteGoodsPackage}
                            setSta={this.setSta}
                        />:''
                }


                {
                    /**
                     * 商家列表、商家审核、商家-商品列表
                     */
                }
                {
                    this.state.navigation.indexOf('商家')>-1?''
                        :
                        <div className="tableInfo" >
                            <div className="tableInfo-data">
                                <div className="tableInfo-data-table" >
                                    <table className="head-body">
                                        {
                                            this.state.menuType==1?
                                                <thead>
                                                <th style={{width: '5%'}}>序号</th>
                                                <th style={{width: '25%'}}>商家名</th>
                                                <th style={{width: '25%'}}>登录手机号</th>
                                                <th style={{width: '25%'}}>创建时间</th>
                                                <th style={{width: '30%'}}>操作</th>
                                                </thead>
                                                :
                                                <thead>
                                                <th style={{width: '5%'}}>序号</th>
                                                <th style={{width: '25%'}}>商家名</th>
                                                <th style={{width: '25%'}}>登录手机号</th>
                                                <th style={{width: '25%'}}>提交审核时间</th>
                                                <th style={{width: '30%'}}>操作</th>
                                                </thead>

                                        }
                                        <tbody>
                                        {Tabels==""?'':Tabels}
                                        </tbody>
                                    </table>
                                    {Tabels==""?<div className="tableNoData">{tableNoDataCount}</div>:''}
                                </div>
                            </div>
                            <Page otherData={this.state.otherData} onPageClick={this.onPageClick} />
                        </div>
                }
                <div className="pop popModel">
                    <div className="model"></div>
                    <div className="pop-info popPhone-info popModel-info">
                        <div className="pop-title popModel-title">
                            <span className="pop-title-content popModel-title-content">
                                <span className="popModel-title-content-solid-left"/>
                                    选择详细地址
                                <span className="popModel-title-content-solid-right"/>
                            </span>
                            <span className="pop-title-img popModel-title-img" onClick={this.onClickHidePop}><img src="../img/icon/close.png" alt="关闭"/></span>
                        </div>
                        <div className="pop-body popModel-body">
                            <div className="map-toolbar">
                                <input id="queryAddressInput" placeholder="请输入关键字搜索" type="text"/>
                                <span onClick={this.isOKAddress.bind(this)}>确定</span>
                            </div>
                            <div id="container" className="map" tabindex="0">

                            </div>
                        </div>
                    </div>
                </div>
                {
                    /**
                     * 新增商品、编辑商品、商品详情
                     */
                }
                <footer id="copyright">
                    <span><img src="../img/icon/copyright.png"/>{copyright}</span>
                </footer>

            </div>
        );
    }
});
/**
 * 获取行政区域组件开始
 * @type {*}
 */
var Address = React.createClass({
    getInitialState:function () {
        return{
            provinceData:[],
            cityData:[],
            countyData:[],
            goods: this.props.goods,//是否启用查询商品地址
        };
    },
    /**
     * 获取点
     */
    poiPickerReady: function () {
        AMapUI.loadUI(['misc/PositionPicker'], function(PositionPicker) {
            var positionPicker = new PositionPicker({
                mode: 'dragMap',
                map: amap
            });
            positionPicker.on('success', function(positionResult) {
                $("#queryAddressInput").val(positionResult.address);
                document.getElementById('adressDetailsInfo').innerHTML = positionResult.position;
                posiResult = positionResult;
            });
            positionPicker.on('fail', function(positionResult) {
                $("#queryAddressInput").val('');
                posiResult = {};
            });
            positionPicker.start();//接收经纬度
            amap.panBy(0, 1);
        });
    },
    /**
     * 初始化地图
     */
    initMap:function () {
        if(amap == undefined){
            amap = new AMap.Map('container', {
                resizeEnable: true,
                zoom: 10,
                // scrollWheel: false//是否能缩放地图
            });
            //地图中添加地图操作ToolBar插件
            amap.plugin(['AMap.ToolBar'], function() {
                //设置地位标记为自定义标记
                // var toolBar = new AMap.ToolBar();
                amap.addControl(new AMap.ToolBar({
                    liteStyle: false
                }));
            });
        }
    },
    /**
     * 修改地址获取经纬度
     * @param type 省市区类型
     */
    getAddressLocation: function (type) {
        var value = '';
        this.initMap();
        if(type==1){
            value = $('#provinceid1').val();
        }else if(type==2){
            value = $('#cityid1').val();
            amap.plugin('AMap.Autocomplete',function(){//回调函数
                let autoOptions = {
                    city:value , //城市，默认全国
                    input: 'queryAddressInput',
                };
                let autocomplete = new AMap.Autocomplete(autoOptions);
                AMap.event.addListener(autocomplete, "select", function(data){
                    amap.setCenter(data.poi.location);
                    this.poiPickerReady();
                }.bind(this));
            }.bind(this));
        }else if(type==3){
            value = $('#countyid1').val();
        }
        amap.setCity(value);//设置地图城市
    },
    /**
     * 获取地址
     * @param num
     * @param province
     * @param city
     */
    queryAddress:function (num,province,city) {
        if(this.state.goods=='true'){
            var uuid = province==''?'china':province;
            var svar = this;
            suixun.ajax(serverUrl+'/region/getRegions.json?uuid='+uuid,'',"get",function(data){
                if(data.code == 200){
                    if(num == "1"){
                        var provinceData = data.info;
                        for(var i = 0 ;i < data.info.length;i++ ){
                            provinceData[i]['value'] = data.info[i].orgName;
                        }
                        svar.setState({provinceData:provinceData});
                    }else if(num == "2"){
                        var cityData = data.info;
                        for(var i = 0 ;i < data.info.length;i++ ){
                            cityData[i]['value'] = data.info[i].orgName;
                        }
                        svar.setState({cityData:cityData});
                    }else{
                        var countyData = data.info;
                        for(var i = 0 ;i < data.info.length;i++ ){
                            countyData[i]['value'] = data.info[i].orgName;
                        }
                        svar.setState({countyData:countyData});
                    }
                }
            });
        }else{
            var param="param={";
            param = getJsonDataNotEmpty(param,"type",'"'+num+'"');
            param = getJsonDataNotEmpty(param,"province",'"'+province+'"');
            param = getJsonDataNotEmpty(param,"city",'"'+city+'"');
            param += "}";
            var svar = this;
            suixun.ajax(serverUrl+'/schoolManage/queryRegion.json',param,"get",function(data){
                if(data.code == 200){
                    if(num == "1"){
                        var provinceData = [];
                        for(var i = 0 ;i < data.info.length;i++ ){
                            provinceData[i] = {value:data.info[i].province};
                        }
                        svar.setState({provinceData:provinceData});
                    }else if(num == "2"){
                        var cityData = [];
                        for(var i = 0 ;i < data.info.length;i++ ){
                            cityData[i] = {value:data.info[i].city};
                        }
                        svar.setState({cityData:cityData});
                    }else{
                        var countyData = [];
                        for(var i = 0 ;i < data.info.length;i++ ){
                            countyData[i] = {value:data.info[i].town};
                        }
                        svar.setState({countyData:countyData});
                    }
                }
            });
        }
    },
    //查询省份
    queryProvince:function () {
        if($("#province"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display')=='none'&&this.state.provinceData.length>0){
            $("#province"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display','block');
            $("#city"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display','none');
            $("#county"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display','none');
            return false;
        }else if(this.state.provinceData.length>0){
            $("#province"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display','none');
            return false;
        }
        if(this.state.goods=='true'){
            this.queryAddress(1,"","");
        }else{
            this.queryAddress(1,"","");
        }
        $("#province"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display','block');
    },
    queryCity:function () {
        if($("#provinceid"+this.props.id+"").next().html()=='选择省份'||$("#province"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display')=='block'){
            return false;
        }
        if($("#city"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display')=='block'){
            $("#city"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display','none');
            return false;
        }
        if(this.state.goods=='true'){
            this.queryAddress(2,$(".span-provinceid"+this.props.id).attr('data-uuid'),"");
        }else{
            this.queryAddress(2,$(".span-provinceid"+this.props.id).html(),"");
        }
        $("#city"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display','block');
        $("#county"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display','none');
        posiResult = {};
    },
    queryCounty:function () {
        if($("#provinceid"+this.props.id+"").next().html()=='选择省份'||$("#cityid").next().html()=='选择地区'||$("#city"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display')=='block'
            ||$("#province"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display')=='block'){
            return false;
        }
        if($("#county"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display')=='block'){
            $("#county"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display','none');
            return false;
        }
        if(this.state.goods=='true'){
            this.queryAddress(3,$(".span-cityid"+this.props.id).attr('data-uuid'),"");
        }else{
            this.queryAddress(3,"",$(".span-cityid"+this.props.id).html());
        }
        $("#county"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display','block');
    },
    /**
     * 显示地图层
     */
    showMap: function () {
        var provinceid1 = $('.span-provinceid1').text();//省
        var cityid1 = $('.span-cityid1').text();//市
        var countyid1 = $('.span-countyid1').text();//区
        //商家地址
        if(provinceid1 =='选择省份' || cityid1=='选择地区' || countyid1=='选择县或街道' ){
            suixun.alert('请选择完整的省市区地址！');
            return;
        }
        $(".popModel").show();
        //初始化地图对象，加载地图
        if(this.props.navigation != '新建商家'){
            this.getAddressLocation(2);
            posiResult = {};
            let adressDetailsInfo = $("#adressDetailsInfo").text();
            console.log(this.props.busTrData.address);
            $("#queryAddressInput").val(this.props.busTrData.address.split('-')[3]);
            let lnglatXY = adressDetailsInfo.split(','); //已知点坐标
            amap = new AMap.Map('container', {
                resizeEnable: true,
                zoom: 10,
                center: lnglatXY
                // scrollWheel: false//是否能缩放地图
            });
            amap.plugin(['AMap.ToolBar'], function() {
                //设置地位标记为自定义标记
                // var toolBar = new AMap.ToolBar();
                amap.addControl(new AMap.ToolBar({
                    liteStyle: false
                }));
            });
        }
    },
    render:function () {
        return(
            <div className="body-content">
                <span className="body-content-title" style={this.props.id==2?{width:'120px',backgroundPosition:'92px 4px'}:{}}>{this.props.id==1?'商家地址':this.props.id==2?'合作意向区域':'商品地址'}：</span>
                <div className="body-address-contents">
                    <div className={"body-address-content body-address-content"+this.props.id+""}  id={"province"+this.props.id} style={{zIndex: this.props.zIndex,display:this.props.id=='3'?this.props.china?'none':'':''}}>
                        <input type="hidden" id={"provinceid"+this.props.id}/>
                        <span className={"body-address-content-default text-sub span-provinceid"+this.props.id+" body-address-content-default"+this.props.id} data-uuid="" title="" onClick={this.queryProvince}>选择省份</span>
                        <AddressData getAddressLocation={this.getAddressLocation} type="1" resultData={this.state.provinceData} id={this.props.id} zIndex={this.props.zIndex}/>
                    </div>
                    <div  className={"body-address-content body-address-content"+this.props.id+""} id={"city"+this.props.id}  style={{zIndex: this.props.zIndex,display:this.props.id=='3'?this.props.china?'none':'':''}}>
                        <input type="hidden" id={"cityid"+this.props.id}/>
                        <span className={"body-address-content-default text-sub span-cityid"+this.props.id+" body-address-content-default"+this.props.id} data-uuid="" title="" onClick={this.queryCity}>选择地区</span>
                        <AddressData type="2" getAddressLocation={this.getAddressLocation}  resultData={this.state.cityData} id={this.props.id} zIndex={this.props.zIndex}/>
                    </div>
                    <div className={"body-address-content body-address-content"+this.props.id+""} id={"county"+this.props.id} style={{zIndex: this.props.zIndex,display:this.props.id=='3'?this.props.china?'none':'':''}} >
                        <input type="hidden" id={"countyid"+this.props.id} value="" data-dataType="Number" data-require="true" data-msg="地区不能为空"/>
                        <span className={"body-address-content-default text-sub span-countyid"+this.props.id+" body-address-content-default"+this.props.id} data-uuid="" title="" onClick={this.queryCounty}>选择县或街道</span>
                        <AddressData type="3" getAddressLocation={this.getAddressLocation}  resultData={this.state.countyData} id={this.props.id} zIndex={this.props.zIndex}/>
                    </div>
                    {
                        this.props.id=='1'?
                            [
                                <div className="content-border adress-details" >
                                    <input type="text" id="adressDetails" className="input-content" readOnly placeholder="请填写详细地址" maxLength="50"/>
                                    <div id="adressDetailsInfo" style={{display:'none'}}></div>
                                </div>,
                                <div className="adress-button" style={{left:'761px'}}>
                                    <div className="header-right-botton" onClick={this.showMap.bind(this)}>设置详情地址</div>
                                </div>
                            ]
                            :this.props.id=='2'?
                            <div className="adress-button">
                                <div className="header-right-botton" onClick={this.props.addAdress.bind(this)}>点击新增</div>
                            </div>
                            :this.props.id=='3'?
                                <div className={this.props.china?'menu-radio-list checkBox select':'menu-radio-list checkBox'} onClick={this.props.goodsSetAddressOrType.bind(this,'china')}><span>全国</span></div>
                                :''
                    }
                </div>
            </div>
        );
    }
});
/**
 * 省市区组装下拉列表
 * @type {*}
 */
var AddressData = React.createClass({
    componentDidMount:function () {
        $(".body-address-content"+this.props.id+"").hover(function () {
        },function () {
            $(".body-address-content-selectData"+this.props.id+"").css('display','none');
        }.bind(this));
    },
    handleClick:function (data,e) {
        if(this.props.type=="1"){
            $("#city"+this.props.id+"").find(".body-address-content-default").html('选择地区');
            $("#county"+this.props.id+"").find(".body-address-content-default").html('选择县或街道');
            this.setState({cityData:[],countyData:[]});
        }else if(this.props.type=="2"){
            this.setState({countyData:[]});
            $("#county"+this.props.id+"").find(".body-address-content-default").html('选择县或街道');
        }
        $(e.target).parent().prev().html(data.value);
        $($(e.target).parent().prev()).attr("title",data.value);
        $($(e.target).parent().prev()).attr("data-uuid",data.uuid);
        $(e.target).parent().prev().prev().val(data.value);
        $($(e.target).parent()).hide();
        if(this.props.id==1){
            this.props.getAddressLocation(this.props.type);
        }
    },
    render:function () {
        var svar = this;
        var resultDATA=this.props.resultData.map(function (value,index) {
            return(
                <span onClick={this.handleClick.bind(this,value)} >{value.value}</span>
            );
        }.bind(this));
        return(
            <div className={"body-address-content-selectData body-address-content-selectData"+this.props.id} style={{zIndex: this.props.zIndex}}>
                {resultDATA}
            </div>
        );
    }
});
/**
 * 商品管理组件
 * @type {*}
 */
var GoodsManger = React.createClass({
    getInitialState: function () {
        return {
            otherData: this.props.otherData,//分页数据
        }
    },
    componentDidMount: function () {
        //时间组件控制
        $('#goodsBeginTime').datetimepicker({
            format: "Y-m-d", //格式化日期  H:i
            timepicker: false, //显示时间选项
            todayButton: false, //关闭选择今天按钮
            step: 1,//时间间隔
            minDate: suixun.getNowFormatDate('yyyy-MM-dd'), // ,new Date(new Date().getTime()+24*60*60*1000)
        });
        $('#goodsEndTime').datetimepicker({
            format: "Y-m-d", //格式化日期 H:i
            timepicker: false, //显示时间选项
            todayButton: false, //关闭选择今天按钮
            step:1,//时间间隔
            minDate: suixun.getNowFormatDate('yyyy-MM-dd'), // and tommorow is maximum date calendar
        });
        $('#goodsUseBeginTime').datetimepicker({
            datepicker:false,//关闭日期选项
            format:'H:i',//格式化日期
            // timepicker: false, //显示时间选项
            todayButton: false, //关闭选择今天按钮
            step:1,//时间间隔
            // minDate: suixun.getNowFormatDate('HH:MM'), // and tommorow is maximum date calendar
        });
        $('#goodsUseEndTime').datetimepicker({
            datepicker:false,//关闭日期选项
            format:'H:i',//格式化日期
            // timepicker: false, //显示时间选项
            todayButton: false, //关闭选择今天按钮
            step:1,//时间间隔
            // minDate: suixun.getNowFormatDate('HH:MM'), // and tommorow is maximum date calendar
        });
        if(goodUE != undefined){
            UE.delEditor('goodsTintroduce');
            if(this.props.navigation=='商家详情>商品详情'){
                goodUE = suixun.editor('goodsTintroduce');//初始化富文本
                setTimeout(function () {
                    goodUE.setDisabled('fullscreen');
                },200);
            }else{
                goodUE = suixun.editor('goodsTintroduce');//初始化富文本
                setTimeout(function () {
                    goodUE.setEnabled();
                },200);
            }
        }else{
            goodUE = suixun.editor('goodsTintroduce');//初始化富文本
        }

    },

    /**
     * 分页
     * @param num
     */
    onPageClick: function (num) {
        this.props.goodsPageClick(num);
    },
    /**
     * 券有效期 改变生效时间
     * @param e
     */
    changeBeginTime: function (element,e) {
        if(new Date($('#'+element).val())<new Date(e.target.value)){
            $('#'+element).val('')
        };
        $('#'+element).datetimepicker({
            format: "Y-m-d", //格式化日期
            timepicker: false, //显示时间选项
            todayButton: false, //关闭选择今天按钮
            step:1,//时间间隔
            minDate: e.target.value, // and tommorow is maximum date calendar
        });
    },
    /**
     * 商品列表——编辑商品
     * @param trData  表单一行的数据
     * @returns {XML}
     */
    onClickEdit: function (trData) {
        this.getGoodsDetails(trData.id,'商家详情>编辑商品');
    },
    /**
     * 商品列表——商家详情
     * @param trData  表单一行的数据
     * @returns {XML}
     */
    goodsDetails: function (trData) {
        this.getGoodsDetails(trData.id,'商家详情>商品详情');
    },
    /**
     * 获取商品详情
     * @param id 商品的ID
     * @param navigation 导航的名称
     */
    getGoodsDetails: function (id,navigation) {
        suixun.showLoding();//显示加载中
        suixun.ajax(serverUrl+'/credits/goods/archives/find_details.json?id='+id,'',"get",function(data){
            suixun.hideLoding();//隐藏加载中
            if(data.code == 200){
                this.setGoodsNavigation(navigation);
                if(data.info.data && data.info.list){
                    /**
                     * 已选地区--组装数据
                     * 有2中情况，1、没有地址 2、1个或者多个地址
                     */
                    var addressOrType = {
                        isShowAddress: true,//是否显示商品地址
                        parent: false,//是否家长
                        teacher: false,//是否老师
                        china: false,//是否显示省市区
                    };
                    data.info.data['address'] = [];
                    /**
                     * 商品地区
                     */
                    if(data.info.list[0] != undefined){
                        for(let j = 0;j<data.info.list.length;j++){
                            let formOtherData = data.info.list[j];
                            let addressInfo = {
                                isShowAddress: false,//是否显示商品地址
                                parent: false,//是否家长
                                teacher: false,//是否老师
                                china: false,//是否显示省市区
                                areaId: '',//区的id
                                putRange: '',
                                province: '',
                                provinceUuid: '',
                                city: '',
                                cityUuid: '',
                                town: '',
                                townUuid: '',
                            };
                            addressInfo.areaId = formOtherData.areaId;
                            addressInfo.putRange = formOtherData.putRange;
                            /**
                             * 商品使用对象
                             */
                            if(formOtherData.putRange=='0'){
                                addressInfo.parent = true;
                                addressInfo.teacher = true;
                            }else if(formOtherData.putRange=='1'){
                                addressInfo.parent = false;
                                addressInfo.teacher = true;
                            }else if(formOtherData.putRange=='2'){
                                addressInfo.parent = true;
                                addressInfo.teacher = false;
                            }
                            if(formOtherData.areaId=='china'){
                                addressInfo.isShowAddress = true;
                                addressInfo.china = true;
                                data.info.data.address.push(addressInfo);
                            }else if(formOtherData.areaId!=''&&formOtherData.areaId!='china'){
                                addressInfo.isShowAddress = true;
                                addressInfo.china = false;
                                addressInfo.town = formOtherData.areaName;
                                addressInfo.townUuid = formOtherData.areaId;
                                suixun.showLoding();//显示加载中
                                suixun.ajax(serverUrl+'/region/getPRegion.json?uuid='+formOtherData.areaId,'',"get",function(cityidData){
                                    suixun.hideLoding();//隐藏加载中
                                    if(cityidData){
                                        addressInfo.city = cityidData.info.orgName;
                                        addressInfo.cityUuid = cityidData.info.uuid;
                                        suixun.showLoding();//显示加载中
                                        suixun.ajax(serverUrl+'/region/getPRegion.json?uuid='+cityidData.info.uuid,'',"get",function(provinceidData){
                                            suixun.hideLoding();//隐藏加载中
                                            if(provinceidData){
                                                addressInfo.province = provinceidData.info.orgName;
                                                addressInfo.provinceUuid = provinceidData.info.uuid;
                                                data.info.data.address.push(addressInfo);
                                                this.goodsSetGoodsTrData(data.info.data);
                                            }
                                        }.bind(this));
                                    }
                                }.bind(this));
                            }
                        }
                    }else{
                        let addressInfo = {
                            isShowAddress: false,//是否显示商品地址
                            parent: false,//是否家长
                            teacher: false,//是否老师
                            china: false,//是否显示省市区
                            areaId: '',
                            putRange: '',
                            province: '',
                            provinceUuid: '',
                            city: '',
                            cityUuid: '',
                            town: '',
                            townUuid: '',
                        };
                        data.info.data.address.push(addressInfo);
                    }
                    // var smallImg = $.parseJSON(data.info.data.smallImg);
                    var smallImg = data.info.data.smallImg=="缩略图地址"?{goodsHeaderImg:'',couponImg:'',couponImg:''}:$.parseJSON(data.info.data.smallImg);
                    this.props.changeImgData(2,{ updateImg: false,showImg: true,imgUrl:smallImg.goodsHeaderImg});
                    this.props.changeImgData(3,{ updateImg: false,showImg: true,imgUrl:smallImg.goodsDetailsImg});
                    if(smallImg.couponImg==suixun.imagesUrl || smallImg.couponImg==''){
                        this.props.changeImgData(4,{ updateImg: false,showImg: false,imgUrl:smallImg.couponImg});
                    }else{
                        this.props.changeImgData(4,{ updateImg: false,showImg: true,imgUrl:smallImg.couponImg});
                    }
                    goodUE.ready(function() {//编辑器初始化完成再赋值
                        goodUE.setContent(decodeURIComponent(data.info.data.contents));  //赋值给UEditor
                    });
                    let goodsPackage = [];
                    if(data.info.data.goodsPackage){
                        this.props.setSta({goodsPackageData:JSON.parse(data.info.data.goodsPackage)});
                    }
                    if(navigation=='商家详情>编辑商品'){
                        $('#goodsName').val(data.info.data.name);//商品名
                        $('#goodsConsumeCredit').val(data.info.data.consumeCredit);//商品消耗积分
                        $('#goodsPrice').val(data.info.data.price);//商品市场价值
                        $('#goodsType').val(data.info.data.goodsType);//商品类型
                        $('#goodsApplyType').val(data.info.data.cardType);//适用对象
                        var beginTime = suixun.getNowFormatDate('yyyy-MM-dd',new Date(data.info.data.beginTime));
                        var endTime = suixun.getNowFormatDate('yyyy-MM-dd',new Date(data.info.data.endTime));
                        $('#goodsBeginTime').val(beginTime);//生效时间
                        $('#goodsEndTime').val(endTime);//失效时间
                        $('#goodsValidRemark').val(data.info.data.validRemark);//券有效时间备注

                        if(data.info.data.useTime){
                            let useTime = data.info.data.useTime;
                            $('#goodsUseBeginTime').val(useTime.split('&')[0].split('—')[0].replace(/ /g,''));//使用开始时间
                            $('#goodsUseEndTime').val(useTime.split('&')[0].split('—')[1].replace(/ /g,''));//使用结束时间
                            $('#goodsUseTimeRemarks').val(useTime.split('&')[1]?useTime.split('&')[1].replace(/ /g,''):'');//使用时间备注
                        }
                        $('#goodsProperty').val(data.info.data.cardProperty?data.info.data.cardProperty:'1');//商品属性
                        $('#goodsNum').val(data.info.data.num);//库存

                        $('#goodsExplain').val(data.info.data.instructions==null?'':data.info.data.instructions.replace(/<br \/>/g,'\n'));//商品介绍
                        this.goodsSetGoodsTrData(data.info.data);
                        this.goodsSetAddressOrTypeAll(addressOrType);
                    }else{
                        suixun.showLoding();//显示加载中
                        suixun.ajax(serverUrl+'/credits/goods/archives/count_goods_info.json?archivesid='+data.info.data.id,'',"get",function(countGoodsData){
                            suixun.hideLoding(200);//隐藏加载中
                            if(countGoodsData.code == 200){
                                data.info.data['totalNum'] = countGoodsData.info.data.totalNum;
                                data.info.data['consumeNum'] = countGoodsData.info.data.consumeNum;
                                data.info.data['notConsumeNum'] = countGoodsData.info.data.notConsumeNum;
                                this.goodsSetGoodsTrData(data.info.data);
                                this.goodsSetAddressOrTypeAll(addressOrType);
                            }else{
                                suixun.alert(data.msg)
                            }
                        }.bind(this));
                    }
                }
            }else{
                suixun.alert(data.msg);
            }
        }.bind(this));
    },
    /**
     * 设置导航名称
     * @return {XML}
     */
    setGoodsNavigation: function (name) {
        var addressOrType = {
            isShowAddress: true,//是否显示商家地址
            parent: false,//是否家长
            teacher: false,//是否老师
            china: false,//是否显示省市区
        };
        this.props.changeImgData(2,{ updateImg: true,showImg: false,imgUrl:''});
        this.props.changeImgData(3,{ updateImg: true,showImg: false,imgUrl:''});
        this.props.changeImgData(4,{ updateImg: true,showImg: false,imgUrl:''});
        this.goodsSetAddressOrTypeAll(addressOrType);
        this.props.setNavigation(name);
    },

    /**
     * 删除商品
     * @param info goodsTrData
     */
    goodsDelete: function (info) {
        var svar = this;
        suixun.confirm_noTit('确定删除此商品?',function (data) {
            if(data == true){
                suixun.showLoding();//显示加载中
                suixun.ajax(serverUrl+'/credits/goods/archives/delete.json?id='+info.id,'',"get",function(data){
                    suixun.hideLoding(200);//隐藏加载中
                    if(data.code == 200){
                        suixun.alert("删除成功!",function (data) {
                            if(data){
                                svar.onPageClick(currentpage);//更新数据
                            }
                        })
                    }else{
                        suixun.alert("删除失败!")
                    }
                });
            }
        });
    },
    /**
     * 改变是否显示
     */
    changAddressOrType: function () {
        if($("#goodsIsShowType").val()=='false'){
            this.goodsSetAddressOrType('isShowAddress');
        }else{
            var addressOrType = {
                isShowAddress: true,//是否显示商家地址
                parent: false,//是否家长
                teacher: false,//是否老师
                china: false,//是否显示省市区
            };
            this.props.setAddressOrTypeAll(addressOrType);
        }
    },
    /**
     * 设置商家地址是否显示 是否选择全国 商品使用对象家长或者老师
     * @param key 设置的值
     */
    goodsSetAddressOrType: function (key) {
        this.props.setAddressOrType(key);
        // this.state.addressOrType[key] = !this.state.addressOrType[key];
        // this.setState({addressOrType:this.state.addressOrType});
    },
    /**
     * 设置商品行数据
     * @param value 设置的值
     */
    goodsSetGoodsTrData: function (value) {
        this.props.setGoodsTrData(value);
    },
    /**
     * 设置商品AddressOrType
     * @param value 设置的值
     */
    goodsSetAddressOrTypeAll: function (value) {
        this.props.setAddressOrTypeAll(value);
    },
    /**
     * 新增商品
     *
     */
    addGoods: function () {
        var name = $('#goodsName').val();//商品名
        var consumeCredit = $('#goodsConsumeCredit').val();//商品消耗积分
        var goodsType = $('#goodsType').val();//商品类型
        var goodsApplyType = $('#goodsApplyType').val();//设备类型
        var goodsPrice = $('#goodsPrice').val();//商品市场价值
        var beginTime = $('#goodsBeginTime').val();//生效时间
        var endTime = $('#goodsEndTime').val();//失效时间
        var goodsValidRemark = $("#goodsValidRemark").val();//劵有效期备注
        var goodsUseBeginTime = $('#goodsUseBeginTime').val();//开始时间
        var goodsUseEndTime = $('#goodsUseEndTime').val();//开始时间
        var goodsUseTimeRemarks = $("#goodsUseTimeRemarks").val();//使用时间备注
        // var goodsIsTop = $("#goodsIsTop").val();//是否置顶
        var useTime = '';//使用时间
        var goodsProperty = $("#goodsProperty").val();//商品属性
        var num = $('#goodsNum').val();//库存

        if(this.props.navigation=='商家详情>编辑商品'){
            num = $('#goodsNum').text();//库存
        }
        var goodsExplain = $("#goodsExplain").val();//使用规则
        var contents = goodUE.getContent();//获取编辑的内容


        //商家地址
        var provinceid3 = $('.span-provinceid3').text();//省
        var cityid3 = $('.span-cityid3').text();//市
        var countyid3 = $('.span-countyid3').text();//区
        var areaId = $('.span-countyid3').attr('data-uuid');// addressOrType.isShowAddress为true时传值
        //合作意向区域---已选地区
        var addressOrType = this.props.addressOrType;

        /**
         * 验证
         */
        //商品名
        if(name == ''){
            suixun.alert('商品名不能为空！');
            return;
        }
        //商品地址
        if(addressOrType.isShowAddress && !addressOrType.china){
            if(provinceid3 =='选择省份' || cityid3=='选择地区' || countyid3=='选择县或街道'){
                suixun.alert('请选择完整的省市区地址！');
                return;
            }
        }
        //商品消耗积分
        if(consumeCredit == ''){
            suixun.alert('商品消耗积分不能为空！');
            return;
        }else if(!/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(consumeCredit)){
            suixun.alert('商品消耗积分格式错误！');
            return;
        }
        //商品消耗积分
        if(goodsPrice == ''){
            suixun.alert('商品市场价值不能为空！');
            return;
        }else if(!/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(goodsPrice)){
            suixun.alert('商品市场价值格式错误！');
            return;
        }
        //生效时间
        if(beginTime == ''){
            suixun.alert('生效时间不能为空！');
            return;
        }
        //失效时间
        if(endTime == ''){
            suixun.alert('失效时间不能为空！');
            return;
        }
        if(new Date(beginTime) > new Date(endTime)){
            suixun.alert('生效时间不能大于失效时间！');
            return;
        }

        //开始时间
        if(goodsUseBeginTime == '' && goodsUseEndTime != ''){
            suixun.alert('结束时间有值时，开始时间不能为空！');
            return;
        }else if(goodsUseBeginTime != '' && goodsUseEndTime == ''){
            suixun.alert('开始时间有值时，结束时间不能为空！');
            return;
        }else if((goodsUseBeginTime != '' && goodsUseEndTime != '') && new Date(goodsUseBeginTime) < new Date(suixun.getNowFormatDate('yyyy-MM-dd'))){
            suixun.alert('开始时间不能小于当前时间！');
            return;
        }else if(new Date(goodsUseBeginTime) > new Date(goodsUseEndTime)){
            suixun.alert('开始时间不能大于结束时间！');
            return;
        }else if((goodsUseTimeRemarks != '' && goodsUseBeginTime == '') ||(goodsUseTimeRemarks != '' && goodsUseEndTime == '') ){
            suixun.alert('开始时间和结束时间不能为空！');
            return;
        }else if(goodsUseTimeRemarks != '' && goodsUseBeginTime != '' && goodsUseEndTime != ''){
            useTime = goodsUseBeginTime+' — '+goodsUseEndTime+'&  '+goodsUseTimeRemarks;
        }else if(goodsUseBeginTime != '' && goodsUseEndTime != ''){
            useTime = goodsUseBeginTime+' — '+goodsUseEndTime;
        }


        //库存
        if(num == ''){
            suixun.alert('库存不能为空！');
            return;
        }else if(!/^[1-9]\d*$/.test(num)){
            suixun.alert('库存格式不对！');
            return;
        }

        //图片头图
        if(this.props.imgData[2].updateImg&&this.props.imgData[2].imgUrl==''){
            suixun.alert('请上传商品图片头图！');
            return;
        }
        //图片详情图
        if(this.props.imgData[3].updateImg&&this.props.imgData[3].imgUrl==''){
            suixun.alert('请上传商品图片详情图！');
            return;
        }
        //使用规则
        if(goodsExplain == ''){
            suixun.alert('使用规则不能为空！');
            return;
        }
        //商品介绍
        if(contents == ''){
            suixun.alert('商品介绍不能为空！');
            return;
        }else if(contents !=''){
            contents = contents.replace(/<table/g,'<div style="overflow: auto;  width: 100%;"><table');
            contents = contents.replace(/<\/table>/g,'<\/table><\/div>');
            contents = encodeURIComponent(contents);
        }
        goodsExplain = suixun.TransferString(goodsExplain,'<br />' );
        if(addressOrType.china){
            areaId = 'china';
        }

        /**
         * 组装数据-JSON
         */
        var paramData = {
            "companyId": this.props.busTrData.id,
            "name": name,
            "goodsType": goodsType,
            "consumeCredit": consumeCredit,
            "price": goodsPrice,
            // "beginTime": this.props.navigation=='商家详情>新增商品'?beginTime+':00':beginTime,
            // "endTime": this.props.navigation=='商家详情>新增商品'?endTime+':59':endTime,
            "beginTime": beginTime+' 00:00:00',
            "endTime": endTime+' 23:59:59',
            "num": num,
            "instructions": goodsExplain,
            "cardType": goodsApplyType,
            "contents": contents,
            "smallImg": '',
            "useTime": useTime,
        };

        // if(goodsProperty != 0){
        paramData['cardProperty'] = goodsProperty;
        // }
        if(goodsValidRemark != ''){
            paramData['validRemark'] = goodsValidRemark;
        }
        if(this.props.goodsPackageData.length>0){
            var isValue = this.props.goodsPackageData.every(function (obj, index) {
                if(obj.name == '' || obj.number == '' || obj.price == ''){
                    return false;
                }else{
                    return true;
                }
            });
            if(isValue){
                paramData['goodsPackage'] = JSON.stringify(this.props.goodsPackageData);
            }else{
                suixun.alert('套餐类容不能为空！');
                return;
            }

        }else{
            paramData['goodsPackage'] = '';
        }
        paramData['isTop'] = false;//置顶默认为false
        /**
         * 图片格式
         */
        suixun.showLoding();//显示加载中
        //_header 商品图片头图 _goodsDetails 商品图片详情图 _coupon 商品优惠券图片
        if(this.props.navigation=='商家详情>新增商品'){
            //putRange与areaId同时存在或不存在
            if(addressOrType.isShowAddress&&addressOrType.parent&&addressOrType.teacher){
                paramData['putRange'] = 0;
                paramData['areaId'] = areaId;
            }else if(addressOrType.isShowAddress&&!addressOrType.parent&&addressOrType.teacher){
                paramData['putRange'] = 1;
                paramData['areaId'] = areaId;
            }else if(addressOrType.isShowAddress&&addressOrType.parent&&!addressOrType.teacher){
                paramData['putRange'] = 2;
                paramData['areaId'] = areaId;
            }
            suixun.uploadImg('#file_header','',function (img_header) {//_header
                suixun.uploadImg('#file_goodsDetails','',function (img_goodsDetails) {//_goodsDetails
                    if(this.props.imgData[3].imgUrl==''){
                        paramData.smallImg= '{"goodsHeaderImg": "'+suixun.imagesUrl+img_header+'","goodsDetailsImg": "'+suixun.imagesUrl+img_goodsDetails+'","couponImg": ""}';
                        suixun.showLoding();//显示加载中
                        this.changeGoods(serverUrl+'/credits/goods/archives/insert.json',paramData);
                    }else{
                        suixun.uploadImg('#file_coupon','',function (img_coupon) {//_coupon
                            paramData.smallImg= '{"goodsHeaderImg": "'+suixun.imagesUrl+img_header+'","goodsDetailsImg": "'+suixun.imagesUrl+img_goodsDetails+'","couponImg": "'+suixun.imagesUrl+img_coupon+'"}';
                            suixun.showLoding();//显示加载中
                            this.changeGoods(serverUrl+'/credits/goods/archives/insert.json',paramData);
                        }.bind(this));
                    }
                }.bind(this));
            }.bind(this));
        }else if(this.props.navigation=='商家详情>编辑商品'){//编辑商家
            // var smallImg = $.parseJSON(this.props.goodsTrData.smallImg);
            var smallImg = this.props.goodsTrData.smallImg=="缩略图地址"?{goodsHeaderImg:'',couponImg:'',couponImg:''}:$.parseJSON(this.props.goodsTrData.smallImg);
            var url = serverUrl+'/credits/goods/archives/update.json',
                img_header_b = false,
                img_goodsDetails_b = false,
                img_coupon_b = false,
                header = smallImg.goodsHeaderImg,
                goodsDetails = smallImg.goodsDetailsImg,
                coupon = smallImg.couponImg,
                interval = '';
            paramData['id'] = this.props.goodsTrData.id;//商品ID
            paramData['putRange'] = this.props.goodsTrData.putRange;
            paramData['areaId'] = this.props.goodsTrData.areaId;
            if(this.props.imgData[2].updateImg){
                suixun.uploadImg('#file_header','',function (img_header) {//_header
                    header = suixun.imagesUrl+img_header;
                    img_header_b = true;
                }.bind(this));
            }else{
                img_header_b = true;
            }
            if(this.props.imgData[3].updateImg){
                suixun.uploadImg('#file_goodsDetails','',function (img_goodsDetails) {//_goodsDetails
                    goodsDetails = suixun.imagesUrl+img_goodsDetails;
                    img_goodsDetails_b = true
                }.bind(this));
            }else{
                img_goodsDetails_b = true
            }
            if(this.props.imgData[4].updateImg){
                suixun.uploadImg('#file_coupon','',function (img_coupon) {//_coupon
                    coupon = suixun.imagesUrl+img_coupon;
                    img_coupon_b = true
                }.bind(this));
            }else if(this.props.imgData[4].updateImg&&this.props.imgData[4].imgUrl==''){
                coupon = '';
                img_coupon_b = true
            }else {
                img_coupon_b = true
            }
            interval = setInterval(function () {
                if(img_header_b && img_goodsDetails_b && img_coupon_b){
                    paramData.smallImg= '{"goodsHeaderImg": "'+header+'","goodsDetailsImg": "'+goodsDetails+'","couponImg": "'+coupon+'"}';
                    this.changeGoods(url,paramData);
                    window.clearInterval(interval);
                }
            }.bind(this),500);
        }
    },
    /**
     *
     * 新增、编辑商品
     * @param url
     * @param paramData
     */
    changeGoods: function (url,paramData) {
        suixun.showLoding();//显示加载中
        $.ajax({
            url: url,
            type: 'POST',
            dataType: "json",
            data: paramData,
            success: function(data){
                suixun.hideLoding();//隐藏加载中
                if(data.code == 200){
                    suixun.alert('操作成功!',function (data) {
                        if(data){
                            this.setGoodsNavigation('商家详情');
                            this.onPageClick(currentpage);
                        }
                    }.bind(this));
                }else{
                    suixun.alert(data.msg);
                }
            }.bind(this)
        });

        // suixun.showLoding();//显示加载中
        // suixun.ajax(url,JSON.stringify(paramData),"post",function(data){
        //     suixun.hideLoding();//隐藏加载中
        //     if(data.code == 200){
        //         suixun.alert('操作成功!',function (data) {
        //             if(data){
        //                 this.setGoodsNavigation('商家详情');
        //                 this.onPageClick(currentpage);
        //             }
        //         }.bind(this));
        //     }else{
        //         suixun.alert(data.msg);
        //     }
        // }.bind(this),"application/json; charset=utf-8");
    },
    /**
     * 商品是否置顶
     * @param trData
     * @return {XML}
     */
    setGoodsIsTop: function (trData) {
        let svar = this;
        suixun.confirm_noTit(trData.isTop?'是否取消置顶？':'是否置顶？',function (isOk) {
            if(isOk){
                suixun.showLoding();//显示加载中
                let paramData = {
                    "id": trData.id,
                    "isTop": trData.isTop?!trData.isTop:true,
                };
                $.ajax({
                    url: serverUrl+'/credits/goods/archives/top.json',
                    type: 'POST',
                    dataType: "json",
                    data: paramData,
                    success: function(data){
                        suixun.hideLoding();//隐藏加载中
                        if(data.code == 200){
                            suixun.alert('操作成功!',function (data) {
                                if(data){
                                    svar.setGoodsNavigation('商家详情');
                                    svar.onPageClick(currentpage);
                                }
                            });
                        }else{
                            suixun.alert(data.msg);
                        }
                    }
                });
            }
        })
    },
    render(){
        var goodsTrData = this.props.goodsTrData;
        var useDetailsInfo = this.props.useDetailsInfo;
        var goodsTypeValue = '免费券';//免费券，特价券，抵用券，折扣券
        switch (this.props.goodsTrData.goodsType) {
            case 1:
                goodsTypeValue = '免费券';
                break;
            case 2:
                goodsTypeValue = '特价券';
                break;
            case 3:
                goodsTypeValue = '抵用券';
                break;
            case 4:
                goodsTypeValue = '折扣券';
                break;
            default:
                goodsTypeValue = '未获取到数据';
                break;
        }
        var Tabels = ''
        if(this.props.navigation=='商家详情') {
            Tabels = this.props.goodsTableData.map(function (data, index) {
                var putRanges = data.putRanges == null ? '3' : data.putRanges, putRangesValue = '未投放';
                //0 所有 1 老师 2 家长
                if (putRanges.indexOf('0') > -1 || (putRanges.indexOf('1') > -1 && putRanges.indexOf('2') > -1)) {
                    putRangesValue = '家长教师端';
                } else if (putRanges.indexOf('1') > -1) {
                    putRangesValue = '老师端';
                } else if (putRanges.indexOf('2') > -1) {
                    putRangesValue = '家长端';
                }
                return (
                    <tr>
                        <td style={{width: '5%'}}>{index + 1}</td>
                        <td style={{width: '20%'}}>{data.name}</td>
                        <td style={{width: '15%'}}>{data.uuid}</td>
                        <td style={{width: '15%'}}>{putRangesValue}</td>
                        <td style={{width: '10%'}}>{data.consumeCredit}</td>
                        <td style={{width: '10%'}}>{data.totalNum}</td>
                        <td style={{width: '10%'}}>{data.consumeNum}</td>
                        <td style={{width: '15%'}}>
                            <div className='trButton trLeft trButton' onClick={this.onClickEdit.bind(this, data)}>编辑
                            </div>
                            <div className='trButton trLeft table-select' onClick={this.goodsDetails.bind(this, data)}>
                                详情
                            </div>
                            {
                                data.isTop?
                                    <div className="trButton trLeft table-select trLong" onClick={this.setGoodsIsTop.bind(this, data)} >取消置顶</div>
                                    :
                                    <div className="trButton trLeft table-select" onClick={this.setGoodsIsTop.bind(this, data)} >置顶</div>
                            }
                            <div className='trButton trLeft table-delete' onClick={this.goodsDelete.bind(this, data)}>
                                删除
                            </div>
                        </td>
                    </tr>
                )
            }.bind(this));
        }else{
            Tabels = this.props.useDetailsData.map(function (data,index) {
                return (
                    <tr>
                        <td style={{width: '5%'}}>{index+1}</td>
                        <td style={{width: '15%'}}>{data.name}</td>
                        <td style={{width: '15%'}}>{data.uuid}</td>
                        <td style={{width: '15%'}}>{data.consumeState}</td>
                        <td style={{width: '15%'}}>{data.peopletel}</td>
                        <td style={{width: '20%'}}>{data.acquireTime}</td>
                        <td style={{width: '20%'}}>{data.consumeTime==null?'---':data.consumeTime}</td>
                    </tr>
                )
            }.bind(this));
        }
        var isShowAddressAll = false;
        var addressAll = '';
        var useObjects = '';
        if(goodsTrData.address){
            for(let p = 0;p<goodsTrData.address.length;p++){
                let add = goodsTrData.address[p].province+' '+goodsTrData.address[p].city+' '+goodsTrData.address[p].town;
                if(goodsTrData.address[p].china){
                    add = '全国';
                }
                if(addressAll.indexOf(add)==-1){
                    addressAll += ','+add;
                }
                if(goodsTrData.address[p].isShowAddress){
                    isShowAddressAll = true;
                }
                if(goodsTrData.address[p].parent && useObjects.indexOf('家长') == -1){
                    useObjects += '家长 '
                }
                if(goodsTrData.address[p].teacher && useObjects.indexOf('老师')==-1){
                    useObjects += '老师 '
                }
            }
            addressAll = addressAll.substring(1,addressAll.length);
        }
        return(
            <div >
                <header style={this.props.navigation=='商家详情'?{display:'flex'}:{display:'none'}}>
                    <div className="navigation" style={{width:'100%',display:this.props.navigation=='商家详情'?'block':'none'}}>商品列表</div>
                    <div className="header-right-botton" style={{marginTop:'10px',width:'65px'}} onClick={this.setGoodsNavigation.bind(this,'商家详情>新增商品')}>新增商品</div>
                </header>
                {
                    this.props.navigation=='商家详情>商品详情>使用情况'?
                        <div className="body-content" >
                            <div className="body-content-text" style={{paddingLeft:'0',width:'auto'}} >
                                <div className="content-border element-content noBorder textInput" >领取量：{goodsTrData.totalNum}&nbsp;&nbsp;&nbsp;&nbsp;已使用：{goodsTrData.consumeNum}&nbsp;&nbsp;&nbsp;&nbsp;未使用：{goodsTrData.notConsumeNum}</div>
                            </div>
                        </div>
                        :
                        ''
                }
                <div className="tableInfo"  style={this.props.navigation=='商家详情'||this.props.navigation=='商家详情>商品详情>使用情况'?{display:'block'}:{display:'none'}}>
                    <div className="tableInfo-data">
                        <div className="tableInfo-data-table" >
                            <table className="head-body">
                                {
                                    this.props.navigation == '商家详情>商品详情>使用情况'?
                                        <thead>
                                            <th style={{width: '5%'}}>序号</th>
                                            <th style={{width: '15%'}}>商品名</th>
                                            <th style={{width: '15%'}}>券号</th>
                                            <th style={{width: '15%'}}>
                                                使用状态
                                                <span className={useDetailsInfo.orderProp==3&&useDetailsInfo.type=='ASC'?"triangle-up select":"triangle-up "} onClick={this.props.setUseDetailsInfo.bind(this,3,'ASC')}/>
                                                <span className={useDetailsInfo.orderProp==3&&useDetailsInfo.type=='DESC'?"triangle-bottom select":"triangle-bottom "} onClick={this.props.setUseDetailsInfo.bind(this,3,'DESC')}/>
                                            </th>
                                            <th style={{width: '10%'}}>账号</th>
                                            <th style={{width: '20%'}}>
                                                领取时间
                                                <span className={useDetailsInfo.orderProp==2&&useDetailsInfo.type=='ASC'?"triangle-up select":"triangle-up "} onClick={this.props.setUseDetailsInfo.bind(this,2,'ASC')}/>
                                                <span className={useDetailsInfo.orderProp==2&&useDetailsInfo.type=='DESC'?"triangle-bottom select":"triangle-bottom "} onClick={this.props.setUseDetailsInfo.bind(this,2,'DESC')}/>
                                            </th>
                                            <th style={{width: '20%'}}>
                                                使用时间
                                                <span className={useDetailsInfo.orderProp==1&&useDetailsInfo.type=='ASC'?"triangle-up select":"triangle-up "} onClick={this.props.setUseDetailsInfo.bind(this,1,'ASC')}/>
                                                <span className={useDetailsInfo.orderProp==1&&useDetailsInfo.type=='DESC'?"triangle-bottom select":"triangle-bottom "} onClick={this.props.setUseDetailsInfo.bind(this,1,'DESC')}/>
                                            </th>
                                        </thead>
                                    :
                                        <thead>
                                            <th style={{width: '5%'}}>序号</th>
                                            <th style={{width: '20%'}}>商品名</th>
                                            <th style={{width: '15%'}}>商品号</th>
                                            <th style={{width: '15%'}}>投放对象</th>
                                            <th style={{width: '10%'}}>价值</th>
                                            <th style={{width: '10%'}}>库存</th>
                                            <th style={{width: '10%'}}>销量</th>
                                            <th style={{width: '15%'}}>操作</th>
                                        </thead>
                                }
                                <tbody>
                                    {Tabels==""?'':Tabels}
                                </tbody>
                            </table>
                            {Tabels==""?<div className="tableNoData">{tableNoDataCount}</div>:''}
                        </div>
                    </div>
                    <Page otherData={this.state.otherData} onPageClick={this.onPageClick} />
                </div>
                <div className="body-updateAttendance" style={this.props.navigation=='商家详情>新增商品'?{display:'block'}:this.props.navigation=='商家详情>编辑商品'?{display:'block'}:this.props.navigation=='商家详情>商品详情'?{display:'block'}:{display:'none'}}>
                    <div className="body-content">
                        <div className="body-content-title">商&nbsp;&nbsp;品&nbsp;&nbsp;名：</div>
                        <div className="body-content-text">
                            {
                                this.props.navigation=='商家详情>商品详情'?
                                    <div className="content-border element-content noBorder textInput" >{goodsTrData.name}</div>
                                    :
                                    <div className="content-border">
                                        <input type="text" id="goodsName" className="input-content" placeholder="请填写商品名" maxLength="32"/>
                                    </div>
                            }

                        </div>
                    </div>
                    <div className="body-content">
                        <div className="body-content-title ">商&nbsp;&nbsp;品&nbsp;&nbsp;号：</div>
                        <div className="body-content-text">
                            {
                                this.props.navigation=='商家详情>新增商品'?
                                    <div className="content-border element-content noBorder textInput" >系统自动生成 不需要填写</div>
                                    :
                                    <div className="content-border element-content noBorder textInput" >{goodsTrData.uuid}</div>

                            }

                        </div>
                    </div>
                    <div className="body-content" >
                        <div className="body-content-title">商品类型：</div>
                        <div className="body-content-text">
                            {
                                this.props.navigation=='商家详情>商品详情'?
                                    <div className="content-border element-content noBorder textInput" >{goodsTypeValue}</div>
                                    :
                                    <div className="content-select-border">
                                        <select className="export-factory msgType " id="goodsType" >
                                            {/*免费券，特价券，抵用券，折扣券*/}
                                            <option value="1" selected='selected'>免费券</option>
                                            <option value="2" >特价券</option>
                                            <option value="3" >抵用券</option>
                                            <option value="4" >折扣券</option>
                                        </select>
                                    </div>
                            }
                        </div>
                    </div>
                    <div className="body-content" >
                        <div className="body-content-title" style={{width:'120px',backgroundPosition:'92px 4px'}}>商品适用对象：</div>
                        <div className="body-content-text">
                            {
                                this.props.navigation=='商家详情>商品详情'?
                                    <div className="content-border element-content noBorder textInput" >{goodsTrData.cardType=='0'?'所有用户':goodsTrData.cardType=='1'?'白卡用户':'学生证用户'}</div>
                                    :
                                    this.props.addressOrType.teacher?
                                        <div className="content-select-border">
                                            <select className="export-factory msgType " readOnly id="goodsApplyType">
                                                <option value="0" selected='selected'>所有用户</option>
                                                {/*<option value="1" >白卡用户</option>*/}
                                                {/*<option value="2" >学生证用户</option>*/}
                                            </select>
                                        </div>
                                        :
                                        <div className="content-select-border">
                                            <select className="export-factory msgType " id="goodsApplyType" >
                                                <option value="0" selected='selected'>所有用户</option>
                                                <option value="1" >白卡用户</option>
                                                <option value="2" >学生证用户</option>
                                            </select>
                                        </div>
                            }
                        </div>
                    </div>
                    {
                        this.props.navigation=='商家详情>新增商品'?'':goodsTrData.address?
                                <div>
                                    {
                                        isShowAddressAll?
                                            <div className="body-content">
                                                <div className="body-content-title" style={{width:'120px',backgroundPosition:'92px 4px'}}>商品使用对象：</div>
                                                <div className="content-border element-content noBorder textInput" >{useObjects}</div>
                                            </div>:''
                                    }
                                    <div className="body-content" >
                                        <div className="body-content-title">是否展示：</div>
                                        <div className="body-content-text">
                                            <div className="content-border element-content noBorder textInput" >{isShowAddressAll?'是':'否'}</div>
                                        </div>
                                    </div>
                                    {
                                        isShowAddressAll?
                                            <div className="body-content">
                                                <div className="body-content-title">商品地区：</div>
                                                <div className="body-content-text">
                                                    <div className="content-border element-content noBorder textInput" >{addressAll}</div>
                                                </div>
                                            </div>:''
                                    }

                                </div>
                          :''
                    }
                    {
                        this.props.addressOrType.isShowAddress?this.props.navigation=='商家详情>新增商品'?
                            <div className="body-content">
                                <div className="body-content-title" style={{width:'120px',backgroundPosition:'92px 4px'}}>商品使用对象：</div>
                                    <div className="body-content-text">
                                        <div className={this.props.addressOrType.parent?'menu-radio-list checkBox select':'menu-radio-list checkBox '} onClick={this.goodsSetAddressOrType.bind(this,'parent')}><span>家长</span></div>
                                        <div className={this.props.addressOrType.teacher?'menu-radio-list checkBox select':'menu-radio-list checkBox'} onClick={this.goodsSetAddressOrType.bind(this,'teacher')}><span>老师</span></div>
                                    </div>
                            </div>
                            :'' :''
                    }
                    {
                        this.props.navigation=='商家详情>新增商品'?
                            <div className="body-content" >
                                <div className="body-content-title">是否展示：</div>
                                    <div className="body-content-text">
                                        <div className="content-select-border">
                                            <select className="export-factory msgType" id="goodsIsShowType" selected={this.props.addressOrType.isShowAddress} onChange={this.changAddressOrType.bind(this)}>
                                                <option value="true" >是</option>
                                                <option value="false" >否</option>
                                            </select>
                                        </div>
                                        <span style={{marginLeft:'10px',lineHeight:'30px'}}>说明：选择是则代表商品可在积分商城中进行展示。</span>
                                    </div>
                            </div>
                            :''
                    }
                    {
                        /**
                         * 商品地区
                         */
                    }
                    {
                        this.props.navigation=='商家详情>新增商品'?
                            this.props.addressOrType.isShowAddress?
                                <Address id="3" type='商品地区' zIndex="1003" goods="true" china={this.props.addressOrType.china} goodsSetAddressOrType={this.goodsSetAddressOrType}/>:''
                            :this.props.addressOrType.isShowAddress?'':''
                    }

                    <div className="body-content">
                        <div className="body-content-title" style={{width:'120px',backgroundPosition:'92px 4px'}}>商品消耗积分：</div>
                        <div className="body-content-text">
                            {
                                this.props.navigation=='商家详情>商品详情'?
                                    <div className="content-border element-content noBorder textInput" >{goodsTrData.consumeCredit}</div>
                                    :
                                    <div className="content-border">
                                        <input type="text" id="goodsConsumeCredit" className="input-content" placeholder="请填写商品消耗积分多少积分" maxLength="11"/>
                                    </div>
                            }
                        </div>
                    </div>
                    <div className="body-content">
                        <div className="body-content-title" style={{width:'120px',backgroundPosition:'92px 4px'}}>商品市场价值：</div>
                        <div className="body-content-text">
                            {
                                this.props.navigation=='商家详情>商品详情'?
                                    <div className="content-border element-content noBorder textInput" >{goodsTrData.price}</div>
                                    :
                                    <div className="content-border">
                                        <input type="text" id="goodsPrice" className="input-content" placeholder="请填写商品市场价值" maxLength="11"/>
                                    </div>
                            }
                        </div>
                    </div>
                    <div className="body-content">
                        <div className="body-content-title" >券有效期：</div>
                        <div className="body-content-text" style={this.props.navigation=='商家详情>商品详情'?{display:'block'}:{display:'none'}}>
                            <div className="content-border element-content noBorder textInput" >{suixun.getNowFormatDate('yyyy-MM-dd',new Date(goodsTrData.beginTime))}&nbsp;—&nbsp;{suixun.getNowFormatDate('yyyy-MM-dd',new Date(goodsTrData.endTime))}&nbsp;{goodsTrData.validRemark}</div>
                        </div>
                        <div className="body-content-text" style={this.props.navigation=='商家详情>商品详情'?{display:'none'}:{display:'block'}}>
                            <div className="content-border content-time" >
                                <input type="text" className="input-content input-time" id="goodsBeginTime" placeholder="生效时间" maxLength="50" onBlur={this.changeBeginTime.bind(this,'goodsEndTime')}/>
                            </div>
                            <span className="content-time-line"/>
                            <div className="content-border content-time" >
                                <input type="text" className="input-content input-time" id="goodsEndTime"  placeholder="失效时间" maxLength="50" />
                            </div>
                            <div className="content-border" style={{margin:'0 0 0 20px'}}>
                                <input type="text" id="goodsValidRemark" className="input-content" placeholder="券有效期备注" maxLength="20"/>
                            </div>
                        </div>
                    </div>
                    <div className="body-content">
                        <div className="body-content-title noImg" >使用时间：</div>
                        {
                            this.props.navigation=='商家详情>商品详情'?
                                <div className="body-content-text">
                                    <div className="content-border element-content noBorder textInput" >{goodsTrData.useTime?goodsTrData.useTime.replace('&',' '):''}</div>
                                </div>
                                :
                                <div className="body-content-text">
                                    <div className="content-border content-time" >
                                        {/*onBlur={this.changeBeginTime.bind(this,'goodsUseEndTime')}*/}
                                        <input type="text" className="input-content input-time" id="goodsUseBeginTime" placeholder="开始时间" maxLength="50" />
                                    </div>
                                    <span className="content-time-line"/>
                                    <div className="content-border content-time" >
                                        <input type="text" className="input-content input-time" id="goodsUseEndTime"  placeholder="结束时间" maxLength="50" />
                                    </div>
                                    <div className="content-border" style={{margin:'0 0 0 20px'}}>
                                        <input type="text" id="goodsUseTimeRemarks" className="input-content" placeholder="使用时间备注" maxLength="20"/>
                                    </div>
                                </div>
                        }
                    </div>
                    <div className="body-content" >
                        <div className="body-content-title ">商品属性：</div>
                        <div className="body-content-text" style={{width: '600px'}}>
                            {
                                this.props.navigation=='商家详情>商品详情'?
                                    <div className="content-border element-content noBorder textInput" >
                                        {
                                            goodsTrData.cardProperty==0?'不设置':
                                                goodsTrData.cardProperty==1?'惠':
                                                    goodsTrData.cardProperty==2?'券':
                                                        goodsTrData.cardProperty==3?'团':
                                                            goodsTrData.cardProperty==4?'亲':'不设置'
                                        }
                                    </div>
                                    :
                                    <div className="content-select-border">
                                        <select className="export-factory msgType " selected={goodsTrData.cardProperty?goodsTrData.cardProperty:1} id="goodsProperty">
                                            {/*<option value="0" >不设置</option>*/}
                                            <option value="1" >惠</option>
                                            <option value="2" >券</option>
                                            {/*<option value="3" >团</option>*/}
                                            {/*<option value="4" >亲</option>*/}
                                        </select>
                                    </div>
                            }
                        </div>
                    </div>
                    <div className="body-content">
                        <div className="body-content-title noImg">套餐内容：</div>
                        <div className="body-content-text">
                            {
                                this.props.navigation=='商家详情>商品详情'?
                                    this.props.goodsPackageData.map(function(data, index) {
                                        return (
                                            <div style={{margin:'5px 0 0 0',float: 'left',width:'600px'}}>
                                                <div className="content-border" style={{width: '160px'}}>
                                                    <input type="text" readOnly className="input-content" value={data.name} />
                                                </div>
                                                <div className="content-border"
                                                     style={{width: '160px', marginLeft: '20px'}}>
                                                    <input type="text" readOnly className="input-content" value={data.number} />
                                                </div>
                                                <div className="content-border"
                                                     style={{width: '160px', marginLeft: '20px'}}>
                                                    <input type="text" readOnly className="input-content" value={data.price} />
                                                </div>
                                            </div>
                                        )
                                    }.bind(this))
                                    :
                                    [
                                        this.props.goodsPackageData.map(function(data, index) {
                                            return (
                                                <div style={{margin:'5px 0 0 0'}}>
                                                    <div className="content-border" style={{width: '160px'}}>
                                                        <input type="text" id={"goodsPackageName"+index} className="input-content" value={data.name} onChange={this.props.setGoodsPackage.bind(this,index,'name')} placeholder="请填写套餐名称" maxLength="30"/>
                                                    </div>
                                                    <div className="content-border"
                                                         style={{width: '160px', marginLeft: '20px'}}>
                                                        <input type="text" id={"goodsPackageNum"+index} className="input-content" value={data.number} onChange={this.props.setGoodsPackage.bind(this,index,'number')} placeholder="请填写套餐数量" maxLength="11"/>
                                                    </div>
                                                    <div className="content-border"
                                                         style={{width: '160px', marginLeft: '20px'}}>
                                                        <input type="text" id={"goodsPackagePrice"+index} className="input-content" value={data.price} onChange={this.props.setGoodsPackage.bind(this,index,'price')} placeholder="请填写套餐价值" maxLength="11"/>
                                                    </div>
                                                    <img onClick={this.props.deleteGoodsPackage.bind(this,index)} className="deleteImg" src="../img/icon/delete.png"/>
                                                </div>
                                            )
                                        }.bind(this))
                                        ,
                                        this.props.goodsPackageData.length == 10?<div style={{height:'5px'}}/>:<div className="header-right-botton" onClick={this.props.addGoodsPackage.bind(this)} style={{float:'left',margin:'5px 0px 20px 0px'}}>新增套餐</div>
                                    ]

                            }
                        </div>
                    </div>
                    <div className="body-content">
                        <div className="body-content-title">库&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;存：</div>
                        <div className="body-content-text">
                            {
                                this.props.navigation=='商家详情>新增商品'?
                                    <div className="content-border">
                                        <input type="text" id="goodsNum" className="input-content" placeholder="请填写库存数量" maxLength="11"/>
                                    </div>
                                    :
                                    <div className="content-border element-content noBorder textInput" id="goodsNum" >{goodsTrData.num}</div>
                            }
                        </div>
                    </div>
                    <div className="body-content">
                        <div className="body-content-title" style={{backgroundPosition: '64px 3px'}}>图片头图：</div>
                        <div className="body-content-text content-file">
                            <form name="excelInputForm" className="input-from excelInputFrom" id="excelInputFrom_header" method="post"  style={{display:this.props.navigation=='商家详情>商品详情'?'none':'block'}}>
                                <input type="hidden" className="input-fileImg" name="filename"  />
                                <a href="javascript:;" className="file">
                                    上传图片
                                    <input type="file" name="file" onChange={this.props.onChangFile.bind(this,'_header')}  accept="image/gif,image/jpeg,image/jpg,image/png,image/svg" id="file_header" />
                                </a>
                            </form>
                            {
                                this.props.imgData[2].showImg==true?
                                    <div className="upload-show-img">
                                        {
                                            this.props.navigation=='商家详情>商品详情'?'':<span onClick={this.props.closeImg.bind(this,'_header')}/>
                                        }

                                        <lable className={this.state.navigation=='商家详情>新增商品'?'':'border'}><img onLoad={this.props.imgLoad.bind(this,'_header')} src={this.props.imgData[2].imgUrl} id="showImg_header" onError={this.props.defaultImg.bind(this)} /></lable>
                                    </div>:''
                            }
                            <span className="inputFile-remarks"  style={{display:this.props.navigation=='商家详情>商品详情'?'none':'block'}}>说明：用于积分商城首页的图片,尺寸为：200*200px,大小限制5M</span>
                        </div>
                    </div>
                    <div className="body-content">
                        <div className="body-content-title"  style={{width:'100px',backgroundPosition:'80px 4px'}}>图片详情图：</div>
                        <div className="body-content-text content-file">
                            <form name="excelInputForm" className="input-from excelInputFrom" id="excelInputFrom_goodsDetails" method="post" style={{display:this.props.navigation=='商家详情>商品详情'?'none':'block'}}>
                                <input type="hidden" className="input-fileImg" name="filename"  />
                                <a href="javascript:void(0);" className="file">
                                    上传图片
                                    <input type="file" name="file" onChange={this.props.onChangFile.bind(this,'_goodsDetails')}  accept="image/gif,image/jpeg,image/jpg,image/png,image/svg" id="file_goodsDetails" />
                                </a>
                            </form>
                            {
                                this.props.imgData[3].showImg==true?
                                    <div className="upload-show-img">
                                        {
                                            this.props.navigation=='商家详情>商品详情'?'':<span onClick={this.props.closeImg.bind(this,'_goodsDetails')}/>
                                        }

                                        <lable className={this.state.navigation=='商家详情>新增商品'?'':'border'}><img onLoad={this.props.imgLoad.bind(this,'_goodsDetails')} src={this.props.imgData[3].imgUrl} id="showImg_goodsDetails" onError={this.props.defaultImg.bind(this)} /></lable>
                                    </div>:''
                            }
                            <span className="inputFile-remarks"  style={{display:this.props.navigation=='商家详情>商品详情'?'none':'block'}}>说明：用于商品详情页头部图片展示,尺寸为：宽750*高300px,大小限制5M</span>
                        </div>
                    </div>
                    <div className="body-content">
                        <div className="body-content-title noImg"  style={{width:'100px',backgroundPosition:'80px 4px'}}>优惠券图片：</div>
                        <div className="body-content-text content-file">
                            <form name="excelInputForm" className="input-from excelInputFrom" id="excelInputFrom_coupon" method="post" style={{display:this.props.navigation=='商家详情>商品详情'?'none':'block'}}>
                                <input type="hidden" className="input-fileImg" name="filename"  />
                                <a href="javascript:void(0);" className="file">
                                    上传图片
                                    <input type="file" name="file" onChange={this.props.onChangFile.bind(this,'_coupon')}  accept="image/gif,image/jpeg,image/jpg,image/png,image/svg" id="file_coupon" />
                                </a>
                            </form>
                            {
                                this.props.imgData[4].showImg==true?
                                    <div className="upload-show-img">
                                        {
                                            this.props.navigation=='商家详情>商品详情'?'':<span onClick={this.props.closeImg.bind(this,'_coupon')}/>
                                        }

                                        <lable className={this.state.navigation=='商家详情>新增商品'?'':'border'}><img onLoad={this.props.imgLoad.bind(this,'_coupon')} src={this.props.imgData[4].imgUrl} id="showImg_coupon" onError={this.props.defaultImg.bind(this)} /></lable>
                                    </div>:''
                            }
                            <span className="inputFile-remarks"  style={{display:this.props.navigation=='商家详情>商品详情'?'none':'block'}}>说明：用于资讯文章下方的领券图片展示,尺寸为：宽500*高130px,大小限制5M</span>
                        </div>
                    </div>
                    <div className="body-content">
                        <div className="body-content-title ">使用规则：</div>
                        <div className="body-content-text">
                            {
                                // {goodsTrData.contents}
                                this.props.navigation=='商家详情>商品详情'?
                                    <div className="content-border element-content noBorder " style={{height:'auto',minHeight:'30px',wordWrap: 'break-word'}} dangerouslySetInnerHTML={{__html: goodsTrData.instructions}} />
                                    :
                                    <div className="content-border content-textarea">
                                        <textarea type="text" id="goodsExplain" className="textarea-content" placeholder="请填写使用规则" maxLength="500"/>
                                    </div>
                            }
                        </div>
                    </div>
                    <div className="body-content">
                        <div className="body-content-title ">商品介绍：</div>
                        <div className="body-content-text">
                            <script id="goodsTintroduce" type="text/plain" />
                        </div>
                    </div>

                    {
                        this.props.navigation=='商家详情>商品详情'?
                            <div className="body-content">
                                <div className="body-content-title noImg">创建时间：</div>
                                <div className="body-content-text">
                                    <div className="content-border element-content noBorder textInput" >{goodsTrData.createTime}</div>
                                </div>
                            </div>
                            :
                            <div className="body-content">
                                <span className="body-svae" onClick={this.addGoods.bind(this)}>保存</span>
                            </div>
                    }
                    {
                        this.props.navigation=='商家详情>商品详情'?
                            <div className="body-content" >
                                <div className="body-content-text" style={{paddingLeft:'0',color:'#01b4ee',cursor:'pointer',width:'auto'}} onClick={this.setGoodsNavigation.bind(this,'商家详情>商品详情>使用情况')}>
                                    <div className="header-right-botton" style={{float:'left',marginLeft:'0',marginRight:'20px'}}>使用详情</div><div className="content-border element-content noBorder textInput" >领取量：{goodsTrData.totalNum}&nbsp;&nbsp;&nbsp;&nbsp;已使用：{goodsTrData.consumeNum}&nbsp;&nbsp;&nbsp;&nbsp;未使用：{goodsTrData.notConsumeNum}</div>
                                </div>
                            </div>
                            :''
                    }

                    {
                        this.props.navigation=='商家详情>商品详情'?
                            <div className="body-content" style={{marginBottom:'20px'}}>
                                <div className="body-content">
                                    <span className="body-svae" style={{marginLeft:'120px'}} onClick={this.onClickEdit.bind(this,goodsTrData)}>编辑</span>
                                    <span className="body-svae" style={{marginLeft:'320px',background: 'rgb(259,89,89)'}} onClick={this.goodsDelete.bind(this,goodsTrData)}>删除</span>
                                </div>
                            </div>
                            :''
                    }
                </div>
            </div>
        )
    }
});

ReactDOM.render(
    <Main  otherData={otherData} />,
    document.getElementById('tableManage')
);
/**
 * 点击下拉框——下拉框依赖
 */
$(".droup-type").click(function () {
    var dropDown = $('.left-drop-down');
    if(dropDown.is(":hidden")){
        dropDown.slideDown();
    }else{
        dropDown.slideUp();
    }
});
/**
 * 搜索框下拉列表——下拉框依赖
 */
$("*").bind("click",function(e){
    var target = $(e.target);
    if(target.closest(".businessNameList-value").length == 1){
        $("#"+$(target.parent()).attr("data-inputId")+"").val(target.html());
        $(".businessList").hide();
    }else{
        $(".businessList").hide();
    }
});
